Bar*_*zyk 5 xcode ios swift xcode-ui-testing
这是我在代码中设置它的方式:
let userBarButtonItem = UIBarButtonItem(image: userIcon,
style: .Plain,
target: self,
action: Selector("userButtonTapped:"))
userBarButtonItem.accessibilityIdentifier = "userBarButtonItem"
Run Code Online (Sandbox Code Playgroud)
然后在里面UITestCase我需要找到这个:
XCUIApplication().otherElements["userBarButtonItem"] //doesnt work, and the reason is:
Run Code Online (Sandbox Code Playgroud)
断言失败:UI测试失败 - 未找到"userBarButtonItem"匹配的其他内容
有没有办法如何使用谓词来找到它?
UIBarButtonItem没有实现UIAccessibilityIdentification,所以设置accessibilityIdentifier不起作用。
相反尝试
userBarButtonItem.accessibilityLabel = "userBarButtonItem"
然后在测试用例中
XCUIApplication().buttons["userBarButtonItem"]
这应该有效。
更新 :
现在 UIBarButtonItem 确实符合 UIAccessibilityIdentification,因此所有这些都不需要。
| 归档时间: |
|
| 查看次数: |
4240 次 |
| 最近记录: |