【发布时间】:2020-09-30 09:22:54
【问题描述】:
我使用 XCUITest 测试一个允许用户通过从图库中选择照片来选择头像的应用。当我点击打开画廊窗口的按钮时,我可以在 debugDescription 中看到元素。有一个表格,其中包含带有照片的文件夹。问题是当我第一次点击任何单元格时,测试失败并出现错误:
Assertion Failure: UserProfileAndSettingsTests.swift:434: Failed to get matching snapshot: No matches found for Element at index 2 from input {(
Table
)}".
如果我在那里设置断点,那么当我第二次点击任何单元格时,它就会起作用。
命令如下:
XCUIApplication().tables.element(boundBy: 2).cells.element(boundBy: 1).tap()
如果在命令之前我输入了这一行:XCUIApplication().tables.element(boundBy: 2).cells.element(boundBy: 1),它不会失败。尝试tap() 时失败。
【问题讨论】: