我正在尝试实现一个非常简单的测试,但我坚持使用XCUIElementQuery.matching(identifier:)方法。我认为查询UIImageViews 没有按预期工作,但不知道为什么。
我为视图设置了这两个设置:
我有这个测试:
func testRecording() {
XCTAssertEqual(app.staticTexts.matching(identifier: "label").count, 2)
XCTAssertEqual(app.images.matching(identifier: "accept").count, 1)
}
我在哪里查询这两个视图(带有 id 的标签和带有 idlabel的 UIImageView accept)。从这里:app简单地定义为像这样的类属性:let app = XCUIApplication()。
这意味着这个测试应该通过,因为屏幕上有两个staticTextidlabel和一个imageid accept。staticTexts 已成功查询,但matching(identifier:)尝试image使用 id查询时失败accept:

我试图查询很多东西,比如:
app.images.app.tables.app.tables.images.app.tables.cells.images.app.buttons.(也标记为Button辅助功能设置的特征部分)app.staticTexts.(也标记为Static Text辅助功能设置的特征部分)
但没有运气......我在这里做错了什么,或者遗漏了什么?


