在iOS 9上介绍Xcode7的UI测试时,苹果谈到了一件事,那就是一切都来自于可访问性。我想知道是否有人知道如何找出元素上是否有“可用操作”。
我有一个UITableView,其中一些单元格可以通过从右向左滑动显示删除按钮来删除。当VoiceOver打开时,你点击该单元格,它会将该单元格描述为一个按钮,然后显示"Actions Available“。
我想从我的测试中找出这一点,这样我就可以用来验证一些东西是启用的,而另一些东西没有。
有什么想法吗?
发布于 2016-10-11 02:49:40
Swift 3中的语法发生了变化。
let app = XCUIApplication()
let cells = app.tables.cells
cells.element(boundBy: 0).swipeLeft()
cells.element(boundBy: 0).buttons["Delete"].tap()发布于 2015-10-07 07:24:21
我不知道有没有办法从XCUITesting中找出是否有可用的可访问性操作,如果有,是什么。
但是,如果您专门尝试在从右向左滑动单元格后检测"Delete“按钮是否可用,则可以使用类似于
yourCellXCUIElement.buttons.count //How many buttons are visible inside your cell. In a standard UITableViewCell, this will be 0 unless you have exposed the "Delete" button.您还可以获得按钮上的标签,如下所示:
yourCellXCUIElement.buttons.elementAtIndex(0).label //In a standard UITableViewCell that has been swiped left to expose the Delete button, this will return "Delete"这是你想要得到的吗,或者你想要验证的是不同的东西是否被启用了?
https://stackoverflow.com/questions/32979249
复制相似问题