XCTest:在SFSafariViewController中点击“完成”按钮

时间:2018-11-19 08:02:14

标签: xcode xctest xcuitest uitest

我正在打开SFSafariViewController,但找不到“完成”按钮再次离开Safari。

此外,如果我尝试使用swipeRight解决它,那么XCode会创建以后无法在测试中使用的代码

let element = app.children(matching: .window).element(boundBy: 0).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element(boundBy: 2)
    element.swipeRight()

有人知道如何关闭SFSafariViewController吗? (我不需要访问浏览器中的元素)。

enter image description here

1 个答案:

答案 0 :(得分:-1)

这对我有用:

let doneButton = app.buttons["Done"]
waitUntilElementExists(element: doneButton)
doneButton.tap()

waitUntilElementExists我认为这是使其发挥作用的关键,我等待60秒。