下面是我记录XCTest无法访问编程方式添加的UIView在XCTest
let app = XCUIApplication()
let tablesQuery = app.tables
tablesQuery.staticTexts["Video"].tap()
tablesQuery.staticTexts["\tWindowed"].tap()
app.buttons["Launch"].tap()
app.buttons["Popout Video"].tap()
app.children(matching: .window).element(boundBy: 0).children(matching: .other).element(boundBy: 1).tap()
当我试图运行测试的最后一部分就是:
app.children(matching: .window).element(boundBy: 0).children(matching: .other).element(boundBy: 1).tap()
无法访问。它不会抛出任何错误,但不会执行最后一行代码。
我试图参照以下计算器问题解决问题: Xcode UI Tests can't find views that are added programatically
https://developer.apple.com/reference/uikit/uiview
但是,所有这些没有按”似乎解决了这个问题。任何帮助将不胜感激。
我不知道答案,但是如果你看看报告日志,它会告诉你关于它为什么失败的细节。它甚至可能包括一个屏幕截图,显示当时的界面。 – matt