By.id - having issues with element not being found

Hi all,

This might be simple but I am finding hard today make it work:

I am having issue with trying to get By.id working with Android. See below - trying to click on ‘‘nextBtn’’ but all things i try are failing:

  • driver.findElement(AppiumBy.id(“nextBtn”)).click();

  • driver.findElement(By.id(“nextBtn”)).click();

  • other variations too

Can anyone help with what I am doing wrong

Using: [email protected] (automationName ‘UiAutomator2’)

Your id does not have package name as usually have android apps.
You have two options:
1 Disable disableIdLocatorAutocompletion as mentioned in link send by @mykola-mokhnach
2. Use UiAutomator search ->

WebElement el = driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().resourceId(\"nextBtn\")"));
// more to read -> https://developer.android.com/reference/androidx/test/uiautomator/UiSelector

Hi @Aleksei @mykola-mokhnach
Thanks for your feedback, and apologies for following up. I’m still learning
The screenshot below is of code where testID is set. When I run builds locally this appears as ‘accessibilityid’ via appium inspector and when run the automation code(using eclipse) it works fine - finds accessibilityid values no problem

However, when builds run from main company build machine - the elements show as ‘id’
Any known reason for this? - or could it be down to disableIdLocatorAutocompletion not equal true?

@Aleksei - would it be ok to DM you?
i’m coming from manual testing background, with knowledge of coding - but technical aspects of setup is what holding me back. Noone else in company here able help with this as just small team

Any help would be gratefully appreciated

yes.

your app looks like a webView. better switch context to it and proceed as with web using e.g. CSS locator strategy.