首页 > 解决方案 > XCTest:点击 SFSafariViewController 中的“完成”按钮

问题描述

我正在打开一个 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 吗?(我不需要访问浏览器中的元素)。

在此处输入图像描述

标签: xcodexctestxcuitestsfsafariviewcontrolleruitest

解决方案


这对我有用:

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

waitUntilElementExists 我认为它是让它工作的关键,我等了 60 秒。


推荐阅读