The problem is when I try to access back bar button item because it is presented with:
Restaurants
title,Back
titleLike it is on the screens:
Currently I access it like this:
let backButton = XCUIApplication().buttons["Restaurants"]
but it won't work for other cases. It is not universal way. May I somehow set it accessibilityIdentifier or something else?
Generally the back button tends to be the first button element in the navigation bar
app.navigationBars.buttons.element(boundBy: 0).tap()
Based on Aaron Sofaers comment, you can also set the accessibilityIdentifier
directly in Interface Builder.
Here's how you can do it in Swift 3:
app.navigationBars.buttons.element(boundBy: 0).tap()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With