jar*_*ryd 7 ios xcode-ui-testing
有没有办法从第一个单元格的UITest中选择或触发didSelect(如果它存在于集合视图中)?
录制时使用所选单元格中的静态文本.如果使用动态内容从网络填充单元格,并且集合视图可能不包含单元格,则此测试将中断.
Joe*_*tti 24
您可以选择集合视图中的第一个单元格:
let app = XCUIApplication()
app.launch()
let firstChild = app.collectionViews.childrenMatchingType(.Any).elementBoundByIndex(0)
if firstChild.exists {
firstChild.tap()
}
Run Code Online (Sandbox Code Playgroud)
斯威夫特3
let firstChild = app.collectionViews.children(matching:.any).element(boundBy: 0)
if firstChild.exists {
firstChild.tap()
}
Run Code Online (Sandbox Code Playgroud)
从理论上讲,您的测试套件应该使用确定性数据.您应该始终确切地知道将从服务返回多少个单元格及其包含的内容.您可以通过使用种子开发服务器或在运行测试套件时模拟网络请求来实现此目的.
| 归档时间: |
|
| 查看次数: |
7507 次 |
| 最近记录: |