在用户定义的运行时属性中,我将accessibilityIdentifier
的值设置为browseTabBarButton
。
但是当我尝试使用以下命令从UITests
访问它时:
app.tabBars.buttons["browseTabBarButton"]
UITabBarItem
不被承认。为什么?
如果您尝试访问UITabBarItem
来切换标签,您可以通过访问UITabBar
中的按钮以不同的方式实现此目的:
app.tabBars.firstMatch.buttons.element(boundBy: 0).tap()
设置accessibilityLabel
而不是accessibilityIdentifier
。