The problem
When I want to run some tests on my hybrid app (Make on Cordova), I can only access the Native element. When I’m switching to Webview, Appium find it, I can go “in” it with driver.context() but then, nothing is found and the error “Unkown error - Device is not online” appear.
Environment
- Appium version 1.7.1
- Windows 10
- Node.js version (unless using Appium.app|exe):
- Android 7.0
- Device: Samsung S7 Edge
- Appium CLI
- Chromedriver 2.9.248315
Details
If necessary, describe the problem you have been experiencing in more detail.
Link to Appium logs
Appium logs: https://gist.github.com/maloz/7dc4bddfbd3edfdb6bd4b960904ee7e5
My code
` public void setupTest() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app", "C:/APKs/myStart_2.0.7.apk");
capabilities.setCapability("deviceName", "9885b6514930495a35");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "7.0");
URL serverAddress = null;
try {
serverAddress = new URL("http://0.0.0.0:4723/wd/hub");
} catch (MalformedURLException e) {
e.printStackTrace();
}
driver = new AndroidDriver<WebElement>(serverAddress, capabilities);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
@Test
public void myTest() {
System.out.println("AppLogin() :: driver.start() executed");
WebDriverWait wait = new WebDriverWait(driver,15000);
Set<String> availableContexts1 = driver.getContextHandles();
System.out.println("Total No of Context Found Before reaching WebView = "+ availableContexts1.size());
System.out.println("Context Name is "+ availableContexts1);
driver.findElement(By.xpath("//android.widget.FrameLayout[contains(@resource-id,'android:id/content')]")).click(); //WORK
Set<String> availableContexts = driver.getContextHandles();
System.out.println("Total No of Context Found After we reach to WebView = "+ availableContexts.size());
for(String context : availableContexts) {
if(context.contains("WEBVIEW")){
System.out.println("Context Name is " + context);
driver.context(context);
break;
}
}
//Never work
WebElement spinner = driver.findElement(By.xpath("//android.widget.Spinner[@index='0']"));
spinner.click();
}`
Log of the Console:
AppLogin() :: driver.start() executed
Total No of Context Found Before reaching WebView = 2
Context Name is [NATIVE_APP, WEBVIEW_com.systel.mystart.vaud]
Total No of Context Found After we reach to WebView = 2
Context Name is WEBVIEW_com.systel.mystart.vaud