Xcuitest ProgressView标识符硬编码为“进度”当按钮内
创建progressView
并使用.AccessibilityIdendifier
或标准标签时,UI测试能够识别它。
视图:
ProgressView().accessibilityIdentifier("Test")
以下断言通过:
XCTAssert(app.activityIndicators["Test"].exists)
将此progressview
放入按钮
中时,UI测试无法识别它。
视图:
Button(action: {}) {
ProgressView().accessibilityIdentifier("Test")
}
相同的断言失败:
XCTAssert(app.activityIndicators["Test"].exists)
有趣的是,一个人可以在按钮
中使用“进度”来识别progressview
,但是当我拥有多个时,该怎么样?
XCTAssert(app.activityIndicators["In progress"].exists)
为什么此progressView
在按钮中无法通过它的
avessibilityIdentifier
在按钮
中识别?
奖励问题,为什么在app.activityIndicators
下可用 app.progressIndicators ,这是人们期望的吗?
- Xcode 13.3.1
- IOS 15.4
When creating a ProgressView
and using .accessibilityIdentifier
or a standard label, UI tests are able identify it.
The view:
ProgressView().accessibilityIdentifier("Test")
The following assertion passes:
XCTAssert(app.activityIndicators["Test"].exists)
When placing this ProgressView
within a Button
however, UI tests fail to identify it.
The view:
Button(action: {}) {
ProgressView().accessibilityIdentifier("Test")
}
The same assertion fails:
XCTAssert(app.activityIndicators["Test"].exists)
Interestingly, one can use "In progress" to identify the ProgressView
within a Button
, but what about when I have multiple?
XCTAssert(app.activityIndicators["In progress"].exists)
Why is this ProgressView
not identifiable within a Button
via it's accessibilityIdentifier
?
Bonus question, why is this available under app.activityIndicators
but not app.progressIndicators
as one might expect?
- Xcode 13.3.1
- iOS 15.4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设,当您的ProgressView放置在按钮中时,它可能会变成“其他元素”类型,这就是您无法使用'app.activityindicators'找到它的原因。我建议您使用:
或使用LLDB调试时打印出您的应用元素层次结构:
并检查元素的实际类型及其在层次结构中的拟合方式。或者,您可以使用以下方式直接测试它:
编辑:
我不了解最初的问题,因此我将有关您的问题的答案添加到多个现有指标的答案中。在这种情况下,您可能需要避免使用
app.activityIndicators
并这样改进您的查询:使用这些指示:使用这些指示活动指示剂可访问性身份。
I would assume that when your ProgressView is placed inside the button it probably becomes of type 'otherElement' and this is the reason you are unable to find it using 'app.activityIndicators'. I would suggest you print out your app elements hierarchy using:
or while debugging using the lldb:
and check the actual type of the element and how it fits in the hierarchy. Or you could directly test it out using:
Edit:
I did not understand the initial problem so I am adding to the answer about your question for multiple existing indicators. In this case you might want to avoid using
app.activityIndicators
and improve your queries like this:With these you don't even have to use the activityIndicator accessibilityIdentifier.