Appium inspctor works fine but the same element unable to locate via automation code

I am trying to locate an element using appium inspector which I can find it via appium inspector but unable to find it via code. I get the error no such element exception.
I tried using wait for display, exist, enabled all those methods but still got the same error.
But when locating the same element via inspector it can find it.

to help others better understand your issue:

  1. write your code how you looking for element
  2. write page source after your code fails to find element
1 Like

My code

await page.checkBox1.waitForDisplayed({ timeout: 30000, interval: 10 })
await page.checkBox1.click();

Page object
get checkBox1() {
return $('//android.widget.TextView[contains(@text," contract and hereby sign")]/parent::*/child::*[position()=last()-4]')
} –

above one worked

when I used accessibility id or xpath suggested by appium inspector as shown in the below screenshot I was getting no such element exception.


So I am wondering why it was throwing an error.

Such query will be problematic to find in any case. I can try suggest more robust if you provide FULL page source. Better as link to https://gist.github.com/