ui 测试 xcode,如何使用 cellquery 点击表格视图单元格按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39096563/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ui testing xcode, how to tap on a table view cell button with cellquery
提问by Billy Boyo
I am currently doing ui tests for my app and stuck on clicking on the log in button of my app. I am unable to find the element which i have gave the identifier signup button(the element is the 3rd by index, this is not the issue).
我目前正在为我的应用程序进行 ui 测试,并一直点击我的应用程序的登录按钮。我无法找到我提供了标识符注册按钮的元素(该元素是索引的第三个元素,这不是问题)。
let cellQuery = self.app.tables.cells.element(boundBy: 3)
let signInButton = cellQuery.buttons["signup button"]
if signInButton.exists {
signInButton.tap()
}
回答by itsViksIn
If the button is present in the 3rd cell then it should be:
如果按钮出现在第三个单元格中,那么它应该是:
let cellQuery = self.app.tables.cells.element(boundBy: 2)
cellQuery.buttons["signup button"].tap()
If button is 3rd in the cell then add accessibility for the cells and then:
如果按钮是单元格中的第三个,则为单元格添加可访问性,然后:
app.cells["AccessibilityIdentifier"].buttons.element(boundBy: 2).tap()
回答by wayneRooney
Can be done like this:
可以这样做:
XCUIApplication().tables.cells.element(boundBy: 2).buttons["signup button"].tap()