Skip to content Skip to sidebar Skip to footer

Unable To Find An Element In Browser Of The Android Emulator Using Appium And C#

I want to automate mobile web site testing on Android emulator using c# and Appium. There is a simple test scenario I want to automate for the start: 1. Start Browser 2. Find an el

Solution 1:

Sorry for misleading !!! In case of testing web apps in browser the elements should be located as usual elements on the web page ( not as some classes like android.widget.EditText and android.widget.Button). So try for example the following and you will see some result:

    var element = _driver
            .findElementByXPath("//input[@id='lst-ib']");

To get locators you should run the browser on your desktop, open the page and use some tools/extensions like Firebug in Firefox or Firebug Lite in Chrome browser.


Solution 2:

Try these 2 statements:

var element = _driver.FindElement(By.Id("com.android.browser:id/url");
driver.findElementsByXPath("//*[@class='com.android.browser' and @index='1']");

Solution 3:

Update ! The following approach is not for web testing:

Could you try to find the element using xpath?

@FindBy(xpath="//android.widget.EditText[contains(@resource-id, 'url')]")

So in your case you can try the following:

var element = _driver.findElementByXPath("//android.widget.EditText[contains(@resource-id, 'url')]");

Update: in case of testing web apps (not native) you should use web page locators instead of Android classes.


Post a Comment for "Unable To Find An Element In Browser Of The Android Emulator Using Appium And C#"