seleniumselenium-webdriverappiumios-ui-automation

Is there a way to click an element using Partial text or complete Text using Appium


I am trying to click an element with text "No, Thanks" using below code, I tried various options so far such as

driver.findElementByXPath("//*[contains(text(),'THANKS')]").click();

 driver.findElement(By.name("No,THANKS")).click();
 driver.findElementByName("No,THANKS").click();

There is no other element with same text. I am using Appium Driver and Samsung device.


Solution

  • If it is TextView, you can consider the following

    driver.find_element_by_xpath("//android.widget.TextView[@text='No, Thanks']")