What are the necessary changes to be done for iOS source code to see the "Webview" enabled in Hybrid App

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;

You don’t need to change the application source code.
What you do need to do is to use the ‘instrumented’ flag on the application.

Thanks a lot. This worked for me.