Sorin Lica
Sorin Lica

Reputation: 7656

How to add accessibilityIdentifier for UISearchBar?

I tried

self.searchBar.accessibilityTraits = .searchField
self.searchBar.accessibilityIdentifier = "mySearchBar"

in UISearchController but it does not work, I need the accessibilityIdentifier to be visible in Appium for UI testing

Upvotes: 0

Views: 503

Answers (1)

Sorin Lica
Sorin Lica

Reputation: 7656

The solution is to set

self.searchBar.isAccessibilityElement = true
        

Upvotes: 3

Related Questions