I'm trying to test a hybrid app using appium and protractor. If I run my test in android+chrome with simple browser.get()
. The protractor test works, but when running in app it shows an error:
Appium logs shows that it has 2 available context, but when I try to set the context to webview using driver.context('WEBVIEW_com.google.android.gms')
it doesn't work.
I've been googling for days already but none seems to work for me. TIA!
You can use the following method to switch to the webview:
public void switchToWebview() {
Set<String> availableContexts = driver.getContextHandles();
for (String context : availableContexts) {
if (context.contains("WEBVIEW")) {
System.out.println("Context Name is " + context);
driver.context(context);
break;
}
}
}
Let me know if it works fine for you.
You can give Appium Studio a try. You can find here on how to switch context in AppiumStudio. Its a easy to use tool with integrations with various other frameworks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.