【发布时间】:2017-07-18 04:22:13
【问题描述】:
在一个只包含 20 行的表格视图的应用程序中,所有这些都包含文本“单元格 X”,X 是行的索引,我有以下测试:
func testTwentyFirstRow()
{
let cell = XCUIApplication().staticTexts["Cell 20"]
let label = cell.label
XCTAssert(label == "Cell 20", "Label is not equal to Cell 20")
}
此测试在第二行失败并出现以下错误
No matches found for Find: Elements matching predicate '"Cell 20" IN identifiers' from input {(
StaticText, 0x60800019b930, traits: 8589934656, label: 'Cell 0',
...
StaticText, 0x60800019d740, traits: 8589934656, label: 'Cell 19'
)}
是否有任何方法可以防止它在那里失败,但让它在下一行失败,而不是在我断言标签值的地方失败?
【问题讨论】:
标签: swift xctest xcode-ui-testing