Jos*_*osh 1 uitableview ios swift xcode-ui-testing
我正在尝试在基本购物列表应用程序中构建UI测试,确保滑动删除表视图单元格确实从表视图中删除单元格.
我正在运行下面的测试代码,但是当需要向左滑动表格视图单元格(以显示删除按钮)时,它不会滑动.它似乎可能正在点击它,但它不会滑动.因此,尝试点击"删除"按钮时测试失败,因为"找不到匹配按钮".
如何在表格视图中滑动删除以进行删除?
func testDeletingCell() {
let app = XCUIApplication()
app.navigationBars["ShoppingList.ShoppingListView"].buttons["Add"].tap()
let element = app.otherElements.containing(.navigationBar, identifier:"ShoppingList.AddShoppingListItemView").children(matching: .other).element.children(matching: .other).element.children(matching: .other).element
let textField = element.children(matching: .textField).element(boundBy: 0)
textField.tap()
textField.typeText("abc")
let textField2 = element.children(matching: .textField).element(boundBy: 1)
textField2.tap()
textField2.typeText("123")
app.navigationBars["ShoppingList.AddShoppingListItemView"].buttons["Save"].tap()
let tablesQuery = app.tables
tablesQuery.children(matching: .cell).element(boundBy: 0).staticTexts["123"].swipeLeft()
tablesQuery.buttons["Delete"].tap()
XCTAssert(app.tables.cells.count == 0)
}
Run Code Online (Sandbox Code Playgroud)
Ras*_*n L 18
请尝试使用此新Swift 3
语法:
let tablesQuery = app.tables.cells
tablesQuery.element(boundBy: 0).swipeLeft()
tablesQuery.element(boundBy: 0).buttons["Delete"].tap()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2847 次 |
最近记录: |