iOS - Clicking the clear X button on UISearchBar


  1. Is there a way to determine if the UISearchBar X (clear) button appeared?
  2. How click on it programmatically?

Please see screenshot.


Please go to inspector and look for the X element. Any doubt, take a print of inspector

Use inspector, as mentioned previously, or use driver.getPageSource() (for Java), driver.page_source (for Ruby) to get source code.

You can try like this

if (driver.findElements(By.className(“Class Name shown in type field of Appium Inspector”)).size()>0)
driver.findElement(By.className(“Class Name shown in type field of Appium Inspector”).click()