Search and click element by text

Hi,

I started developing some tests for an iOS app, using Python as a programming language. I have some buttons (which for the moments doesn’t have ids) and I was wondering what is the best method to search for example, a button with a certain text and click it.

On Android I’m successfully using:
self.driver.find_element_by_android_uiautomator(“text(“Memory”)”).click()

On iOS I tried using:
self.driver.find_element_by_ios_uiautomation(“text(“ACCEPT”)”).click()

but I get the following error in PyCharm:
selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy ‘-ios uiautomation’ is not supported for this session

Any help, please?

Thanks!

uiAutiomation = Android. With ios you should use predicate.

http://appium.io/docs/en/writing-running-appium/ios/ios-predicate/

@Aleksei I have a scenario in android application, where I am trying to click a button with the help of resource-id, xpath, text, tag but nothing works. I tried with AndroidTouchActions but still no help.

The element shows it performed the click operation in the console but in the device there is no action it remains in the same page.

What else we can try to perform the click

Steps:

  1. enable in developer mode on Android phone to show touches and coordinates
  2. check where actually tap happens
  3. try tap using element coordinates (center of element)
  4. try also switching to w3c actions