Hi,
while trying to automate native app for android, I’m facing the following issue,
Exception in thread “main” org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {stacktrace=NoSuchElementError: An element could not be located on the page using the given search parameters.
at AndroidDriver.callee$0$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-android-driver/lib/commands/find.js:69:13)
at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-android-driver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-android-driver/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-android-driver/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-android-driver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at , error=no such element, message=An element could not be located on the page using the given search parameters.}
Build info: version: ‘3.5.2’, revision: ‘10229a9’, time: '2017-08-21T17:29:55.15Z’
System info: host: ‘USHYDJKUMARR3MB’, ip: ‘fe80:0:0:0:104a:38f2:7a2a:37ee%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.6’, java.version: '1.8.0_171’
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:421)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.j
Versions that I’had used,
Selenium - 3.11.0
appium java client - 5.0.0
guava - 22.0
appium version - 1.8.0
android studio - 3.1.2
please find the following code,
private static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Galaxy S8+");
capabilities.setCapability("platformVersion", "7.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", "/Users/username/Desktop/APK/test.apk");
capabilities.setCapability("appPackage", "com.xxx.android.xxxx.xxx");
capabilities.setCapability("appActivity", "com.xxx.android.xxx.ui.login.LoginActivity");
driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
driver.findElement(By.id("et_member_number")).clear();
driver.findElement(By.id("et_member_number")).sendKeys("6008");
System.out.println(driver.getPageSource()); // able to get the page source with xml content
driver.findElementById("btn_next").click();
System.out.println(driver.getPageSource()); // able to get the page source with xml content
MobileElement Edit_Password = driver.findElementById("et_password");
Thread.sleep(2000);
Edit_Password.sendKeys("favourite user 123");
MobileElement btn_Password = driver.findElementById("btn_login");
btn_Password.click();
Thread.sleep(2000);
MobileElement lnk_Skip = driver.findElementById("skip");
lnk_Skip.click();
Thread.sleep(2000);
driver.findElementById("button1").click();; // able to get the page source with xml content
Thread.sleep(2000);
**// able to perform action on above elements expect this**
driver.findElementById("btn_start").click(); // **unable to get the page source**
}}
The following things have been tried but none of them seems to working,
- Getpagesource() not returning any xml content for the btn_start
- appium desktop doesn’t load the screen for the btn_start (but for all other screens it gets loaded)
- Tried with other java client versions as well but no luck
- getcontext returns NATIVE and I see there is no web component in it but still unable to interact with these
Can I get any help on this …