Search code examples
c#appiumappium-androidappium-desktop

Could not access element by ID


I am facing with problem when I tried to access Android element by ID in C#, I also tried with Appium-desktop version and seems not accessible for example:

I tried with and without package name and there is an exception every time which says could not find element. Also from Appium desktop selector.

AndroidElement selectPlant = driver.FindElementById("com.heidelbergcement.aom.stage.dev:id/loginForm-plantSelection")

Solution

  • You're misunderstanding something.

    FindElementById refers to the unique identifier of the element which in most cases is the RuntimeId of the UI element.

    What you should use is findElementByAccessibilityId, which refers to AutomationId of the UI element as shown in the inspect tool.

    Total credit to this.