Accessibility identifier of UISearchBar's Cancel button

Hi There,

UISearchBar has its own "Cancel" button which can be shown/hidden with the property showsCancelButton. How to access it when writing UI test cases? (Or what is its accessibilityIdentifier). I want to do something like: enter some text in the search bar and then clear it with that button.

Thanks in advance!

You can check the accessibility identifier of elements on your device or simulator by using Accessibility Inspector. The "crosshair" icon will identify any element you tap on, once you press it on your Mac.

You can also print out the debugDescription of any XCUIApplication to determine all of the automate-able elements in it.

Accessibility identifier of UISearchBar's Cancel button
 
 
Q