I'm trying to test my internationalized app in all locales.
Testing the delete function from a List like
app.cells.firstMatch.swipeLeft()
app.buttons["Delete"].tap()
obviously only works when in English / Default language.
The List is defined as follows
List {
ForEach(items) { item in
...
}
.onDelete(perform: deleteItems)
}
With that, there's no delete-button explicitly defined (same as with the navigation bar's back-button).
I couldn't figure out how to add an accessibilityIdentifer so my tests are language agnostic.
(I'm usually adding a .accessibilityIdentifier("AddButton")
in order to reference it properly in the tests)
So how to set this identifier?
Or if it's not possible, what's a feasible way to test it properly?
BTW: I'm using
let navigationBar = app.navigationBars.element(boundBy: 0)
let backButton = navigationBars.buttons.element(boundBy: 0)
already to mitigate the same problem with the back-button and the fact that I can't set an identifier solely to a navigationBar (without setting this accessibilityIdentifier to all elements inside).
However using app.buttons.element(boundBy: app.buttons.count - 1)
doesn't only look ugly, it may also be wrong (delete button doesn't necessarily have to be the last button).
PS: Why do I see 1 Reply in the list when there's actually no reply visible?