Can't Switch Context to Webview

Hello everybody,

I’m testing a hybrid app in real devices, using Appium Server with Appium Library and Robot framework.

I’m able to:

  • run appium server and run test. :heavy_check_mark:

I wan’t to be able to inspect the WebView to find the UI elements necessary to write tests but I can’t because when I Get Contexts I only get NATIVE_APP.

I tried to Switch To Context but without sucess, only NATIVE_APP appears to be available.

info: [debug] Available contexts:
info: [debug] []
info: [debug] Available contexts: NATIVE_APP
info: [debug] Responding to client with success: {“status”:0,“value”:["NATIVE_AP
P"],“sessionId”:“fa8e2bc9-bf14-4d78-9d41-7ccbe240bb89”}

So I went to chrome://inspect/#devices
And I get this :

The SM-N919F its the real device (usb connected) the other apps are just examples.
The last Application listed shows "WebView in … " and the SM-N919F doesn’t have that description, does that means something?

If I go to UI Automator Viewer I can find :

I can’t select the WebView elements because UI Automator Viewer just works for Native.

Any ideas about why I can’t find and switch context to WebView?

As your developers to enable below flag in app and get it rebuilt and u will see webview context and you can also inspect elements in chrome browser.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true); // THIS IS FLAG TO BE ENABLED BY DEV TEAM
}

HAPPY Testing !!!

1 Like

Okey I will check on that. Many thanks!