ui testing xcode, how to tap on a table view cell button with cellquery
Asked Answered
A

2

3

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).

let cellQuery = self.app.tables.cells.element(boundBy: 3)

let signInButton = cellQuery.buttons["signup button"]
if signInButton.exists {
    signInButton.tap()
}
Apostolate answered 23/8, 2016 at 8:51 Comment(1)
A link to a screenshot and a dump of the output of signInButton.debugDescription would be helpful for context.Cimabue
S
10

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()
Seine answered 23/8, 2016 at 22:59 Comment(0)
P
1

Can be done like this:

XCUIApplication().tables.cells.element(boundBy: 2).buttons["signup button"].tap()
Participle answered 14/9, 2016 at 17:13 Comment(1)
This will fail in localized apps. Please consider accessibility identifiers as the locale-agnostic way to handle this.Imphal

© 2022 - 2024 — McMap. All rights reserved.