ios - 使用 EarlGrey 点击 UITabBarItem

标签 ios swift earlgrey

我在尝试使用 Earl Grey 编写 UI 测试时遇到问题,特别是如何在某个 UITabBarItem 上执行点击。

我注意到标签栏项目不允许在 Storyboard 中设置辅助功能 ID 和标签,我尝试在运行时使用 barItem.accessibilityLabel = "label" 但当使用 EarlGrey.select(elementWithMatcher: grey_accessibilityLabel("label")).perform(grey_tap())

引用项目时,这不起作用

有没有办法做到这一点?

最佳答案

如回答here ,您可以使用此匹配器来查找标签栏元素。

匹配器示例

EarlGrey.selectElement(with: grey_text(tabbarTitle))
    .inRoot(grey_kindOfClass(UITabBar.self))
    .perform(grey_tap())

关于ios - 使用 EarlGrey 点击 UITabBarItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44665953/

相关文章:

ios - 仅重置 UIDatePicker 的一部分

ios - iO 中所有 uiviewcontroller 中的操作栏

ios - 从 Objective-C 到 Swift 的桥接后无法识别扩展

ios - 使用 iOS 版 FBSDK 登录卡住

ios - 在 Swift 中使用 UIBackgroundTaskIdentifier 的目的是什么。下面提到的代码将如何执行

cocoapods - Pod 安装失败,错误为 "LoadError - cannot load such file -- earlgrey"

ios - 当我搜索大量 TableViewCells 时,EarlGrey 卡住了一段时间

ios - EarlGrey GREY条件 waitWithTimeout :15 does not wait for 15 seconds

ios - 如何在 Swift 3.0 中一段时间​​后插入警报

iphone - Facebook SDK : How to i get the photo properties after posting an image?