Reputation: 129
am working on android automation using appium & robot framework. for this am using robot's appiumlibrary. so i want to automate facebook login secenario in my application, but the problem is the fb login page on app is embedded to an webview. however in uiautomatorviewer able to focusand and find elements, but while running the scripts it throws an error element not found.
what do i need to do in this scenario. i tried to fetch and then switch to context but there was no new or related context available. NATIVE_APP was the only one available.
Upvotes: 0
Views: 2076
Reputation: 4587
To see the webview context using driver.context()
method WebView debugging should be enabled; developer must enable ‘setWebContentsDebuggingEnabled
’ flag in the WebView
class. This flag enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of app. Once this is done driver.context()
method will return native and webview both contexts.
Set<String> availableContexts = driver.getContextHandles();
System.out.println("Total No of Context Found = "+ availableContexts.size());
for(String context : availableContexts) {
if(context.contains("WEBVIEW")){
System.out.println("Context Name is " + context);
driver.context(context);
break;
}
}
Note - You cannot do this for third party app like facebook because you may not rebuild that app with webview debugger enabled.
Upvotes: 0