【发布时间】:2017-10-26 08:56:27
【问题描述】:
我正在尝试实现一个非常简单的测试,但我坚持使用XCUIElementQuery.matching(identifier:) 方法。我认为查询UIImageViews 没有按预期工作,但不知道为什么。
我为视图设置了这两个设置:
我有这个测试:
func testRecording() {
XCTAssertEqual(app.staticTexts.matching(identifier: "label").count, 2)
XCTAssertEqual(app.images.matching(identifier: "accept").count, 1)
}
我在哪里查询这两个视图(ID 为 label 的标签和 ID 为 accept 的 UIImageView)。从这里开始:app 被简单地定义为像这样的类属性:let app = XCUIApplication()。
这意味着该测试应该通过,因为屏幕上有两个 ID 为 label 的 staticTexts 和一个 ID 为 accept 的 image。 staticTexts 已成功查询,但当 matching(identifier:) 尝试使用 id accept 查询 image 时失败:
我尝试查询很多东西,例如:
app.images.app.tables.app.tables.images.app.tables.cells.images.-
app.buttons.(在辅助功能设置的 Traits 部分中也标记为Button) -
app.staticTexts.(在辅助功能设置的 Traits 部分中也标记为Static Text)
但没有运气......我在这里做错了什么,或者遗漏了什么吗?
【问题讨论】:
标签: ios uiimageview swift4 xctestcase xcuitest