0

I am working on Automation for Android App. While running the script, Appium unable to find the elements. I tried using Id, Xpath. Please help me with this...

Android version: 5.1.1 & 9 Appium Version: 1.13.0 Maven Project

@Test
public void login() {
    driver.findElement(By.xpath("//com.vehito.vehitoplus[contains(@resource-id,'phone')]")).sendKeys("9632642105");
driver.findElement(By.id("com.vehito.vehitoplus:id/sign_in_button")).click();
}

Actual Result: Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters

Gireesh05
  • 1
  • 4

2 Answers2

0

This error said that UIAutomator couldn't able to find that Element.

I found 2 problem with your Xpath code:

1- Replace , with = after resource-id.

2- You use packageName (com.vehito.vehitoplus) instead of the class name.

You can find the exact class name of the element with UIAutomator Viewer:

(Android SDK Dir)\tools\bin\uiautomatorviewer.bat

I mean you may use this: (If the element's class name be: android.widget.EditText )

        driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id='phone')]")).sendKeys("9632642105");

In my experience, I found that By. library (XPath or ID) is not working well with @contains. So it's better if you use exact attributes.

e.g.

        driver.findElement(By.id("com.vehito.vehitoplus:id/sign_in_button")).sendKeys("9632642105");

I hope this helps. If not, please provide a screenshot from the page and also UIAutomator viewer screenshot of this input element.

-1

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' Driver info: io.appium.java_client.android.AndroidDriver Capabilities {app: C:\Selenium\workspace\Ninja..., appPackage: com.ninjafocus.app, appactivity: com.ninjafocus.app.base.vie..., databaseEnabled: false, desired: {app: C:\Selenium\workspace\Ninja..., appPackage: com.ninjafocus.app, appactivity: com.ninjafocus.app.base.vie..., deviceName: Nokia 6, newCommandTimeout: 60, platformName: android, platformVersion: 9, udid: PLEGAR1780410318}, deviceApiLevel: 28, Default suite

    driver.findElementById("\r\n" + "com.ninjafocus.app:id/signinButton").click();
    driver.findElementById("\r\n" + "com.ninjafocus.app:id/parentEmailText").sendKeys("pooja.yadav@gmail.com");
    driver.findElementById("\r\n" + "com.ninjafocus.app:id/parentPasswordText").sendKeys("1234");
    driver.findElementById("\r\n" +"com.ninjafocus.app:id/startedButton").click();