Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61840

How to access UITabBarItem from within UITests?

Within User Defined Runtime Attributes I set accessibilityIdentifier's value as browseTabBarButton.

But when I try to access this from UITests using:

app.tabBars.buttons["browseTabBarButton"]

UITabBarItem is not recognized. Why?

Upvotes: 5

Views: 2747

Answers (2)

rhmac25
rhmac25

Reputation: 266

If you are trying to access the UITabBarItem to switch tabs, you can achieve this in a different way by accessing the buttons within the UITabBar:

app.tabBars.firstMatch.buttons.element(boundBy: 0).tap()

Upvotes: 8

Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61840

Set accessibilityLabel instead of accessibilityIdentifier.

Upvotes: -1

Related Questions