Detecting the WEBVIEW context in iOS hybrid app. IOSDRIVER class provides only NATIVE context and not WEBVIEW context.
When i try to print the getcontext from IOSDriver class, the Webview context is not been returned by this class. Only “NATIVEVIEW” is printed. If same is followed in Android build i see WebVIEW and NATIVE been returned by respective driver class.
Do i need to make any changes to iOS source code before i generate an IPA file? Please help.
The code i am using to get or switch context is:
// Switching to iOS webview
IOSDriver<MobileElement> iosDriver = (IOSDriver<MobileElement>) appiumDriver;
Set<String> contextNames = iosDriver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName); //prints out something like [NATIVE_APP, WEBVIEW_<APP_PKG_NAME>]
if(contextName.contains("WEBVIEW")){
iosDriver.context(contextName);
System.out.println("Switched to: "+contextName);
break;
}
}
return iosDriver;