Search code examples
iosxcodexcode-ui-testing

Can't get UI Testing to select a static table view cell


I'm trying to use UI Tests to take screenshots of my app.

The app is localized, so I can't have the automation look for the text, because it changes according to the current language.

I have a lot of static table views with cells that segue to other view controllers, and I managed to get Xcode to select them by adding accessibility identifiers to their labels and using the identifiers instead of the text.

For other cells, though, that doesn't work, I don't know why. Even if the identifiers are set just like for the other cells, Xcode keeps telling me there were no matches found. Also if I try to record my interaction, for the cells that work Xcode will record the identifier I have set, but for the ones that don't it will just use the label's text. It's like I didn't even set an identifier for those labels, even though I did.

Does anyone have a clue about what's happening here? And are there any better alternatives to select a cell?

Thanks in advance,

Daniel


Solution

  • Well, I still don't know why the accessibility identifiers aren't working for those cells, but I managed to select them using this:

        let cells = app.tables.cells
        cells.elementBoundByIndex(3).tap()