If the View looks like this:
struct Screen: View {
var body: some View {
VStack {
...
NavigationLink {
LoginScreen()
} label: {
Text("Sign in")
}
.accessibilityIdentifier("TEST_IDENTIFIER")
}
}
.accessibilityRepresentation {
NavigationLink {
LoginScreen()
} label: {
Text("Sign in")
}
.accessibilityIdentifier("TEST_IDENTIFIER_2")
...
}
}
and the content of the UITest looks like this:
let signInButtton = app.buttons["TEST_IDENTIFIER"]
signInButtton.tap()
Running some tests shows that the test can only find the signInButton
withe the TEST_IDENTIFIER
, and when it taps, it taps where the representation of the button would be. Unfortunately the visible button is at a different place. So it taps on a different place of the screen and is not triggering any button presses.
Accessibility wise, it would be useful to have both buttons at a different place, but this way we could not find any way to make the UITest work.