Search code examples
iosswiftuikitaccessibility

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


Solution

  • The solution is to set

    self.searchBar.isAccessibilityElement = true