[Appium 1.7.1] [Android 7.0] [Java] [Hybrid App] [Cordova] I tried with following logic to switch context, it's working with another Android OS like 5.1.1 but it's not useful for android 7.0. I am not able to focus on native app after context from webview.
Set<String> availableContexts = driver.getContextHandles();
// switch to Web-view
for(String context : availableContexts) {
if(context.contains("WEBVIEW")){
logger.info("Context Name is " + context);
driver.context(context);
break;
}
}
// switch to Native app
for(String context : availableContexts) {
if(context.contains("NATIVE")){
logger.info("We are Back to " + context);
driver.context(context);
logger.info("Context Switched");
}
}
After switching from web-view, I have kept the application in background for a while as per following, and then resumes execution:
driver.runAppInBackground(Duration.ofSeconds(1));
This is now resolved for issue faced while switching context view from web-view to native view.
please suggest someone have the better approach.