如何编写单元测试反向导航

时间:2018-08-17 09:43:50

标签: swift unit-testing

此错误-> 未找到与“查找:”匹配的谓词,这些谓词来自输入{(     NavigationBar,0x60c0001922e0,特征:35192962023424,标识符:'papon_Workshop03.BTSView' )}

此代码单元测试->

let buttonTest = XCUIApplication()
buttonTest.buttons["Chong Nonsi"].tap()
buttonTest.tables.cells.staticTexts["Wutthakat"].tap() 
buttonTest.navigationBars.______i want to know.what should use method_________

首先我选择按钮

enter image description here

“ Wutthakat”中的第二个tap()

enter image description here

最后我不知道选择navigationBar的方法过程。返回

enter image description here

1 个答案:

答案 0 :(得分:0)

我可以以此编写我的代码

             let app = XCUIApplication()
             app.buttons["Chong Nonsi"].tap()
              app.tables/*@START_MENU_TOKEN@*/.staticTexts["Wutthakat"]/*[[".cells.staticTexts[\"Wutthakat\"]",".staticTexts[\"Wutthakat\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()

              app.navigationBars["papon_Workshop03.BTSView"].buttons["Back"].tap()
             XCTAssertTrue(app.buttons["Wutthakat"].exists)