XCUIApplication 上的 swipeUp() 破坏了 UITest 中的 XCUIApplication
swipeUp() on XCUIApplication breaks the XCUIApplication in UITest
我们进行了一项测试,我们需要 swipeUp
才能看到 tableView
内部的单元格。在 swipeUp
之后我们无法打印出 app.tables
。如果我们不滑动,一切都会按预期工作。
- 那么 Swift 3 与 Swift 2 相比有何变化?
- 我们如何解决这个问题?
示例:
func testSomethingInApp() {
let app = XCUIApplication()
app.launch()
app.swipeUp() //after this we cant get app.tables anymore. Befor everything is fine
XCTAssertEqual(app.tables.cells.elementBoundByIndex(5), "something") //something like this
}
尝试直接访问您的元素...app.staticText["something"]
当我编写 UITests 时,我遇到了一些这样的问题。
我搜索了元素、设置了断点并读取了输出。
使用 po app
命令在控制台中打印 app
。
阅读输出,搜索您想要的元素,查看其类型(如果是静态文本、按钮、其他元素等等...)
看到所有可用的元素都显示在输出中。
输出中每一行的第一个单词是每个元素的类型。
在您的代码中,使用以下方式访问类型:app.buttons
按钮,app.staticTexts
标签等...
吉大
Xcode 9 和 Swift 4.0 确实解决了这个问题。 app.swipeUp()
不再清除 tableview 查询的元素。
我们进行了一项测试,我们需要 swipeUp
才能看到 tableView
内部的单元格。在 swipeUp
之后我们无法打印出 app.tables
。如果我们不滑动,一切都会按预期工作。
- 那么 Swift 3 与 Swift 2 相比有何变化?
- 我们如何解决这个问题?
示例:
func testSomethingInApp() {
let app = XCUIApplication()
app.launch()
app.swipeUp() //after this we cant get app.tables anymore. Befor everything is fine
XCTAssertEqual(app.tables.cells.elementBoundByIndex(5), "something") //something like this
}
尝试直接访问您的元素...app.staticText["something"]
当我编写 UITests 时,我遇到了一些这样的问题。 我搜索了元素、设置了断点并读取了输出。
使用 po app
命令在控制台中打印 app
。
阅读输出,搜索您想要的元素,查看其类型(如果是静态文本、按钮、其他元素等等...)
看到所有可用的元素都显示在输出中。 输出中每一行的第一个单词是每个元素的类型。
在您的代码中,使用以下方式访问类型:app.buttons
按钮,app.staticTexts
标签等...
吉大
Xcode 9 和 Swift 4.0 确实解决了这个问题。 app.swipeUp()
不再清除 tableview 查询的元素。