Unable to find an element in Browser of the Android emulator using Appium and C#

隐身守侯 提交于 2019-12-02 07:59:24

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.

Try these 2 statements:

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!