How to Inspect and Automate Native and Chrome app?

I need to automate the following scenario:

  1. Open native android app.
  2. Get user registration code generated to the current user.
  3. Put the native app in background.
  4. Open Chrome and navigate to proper back-end URL, enter credentials than register the app (using the user registration code).
  5. Go back to the native app…

The problem I have is that I can’t to switch the context. I always get only NATIVE_APP context so that I’m not able to switch to WEBVIEW context and use xPath to traverse the DOM elements. getContextHandles() always return only NATIVE_APP context.

I have been looking for solutions about this problem and after a lot of checks I still can’t handle it.

Capabilities settings:
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID); cap.setCapability(MobileCapabilityType.DEVICE_NAME, DEVICE_NAME); cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); cap.setCapability(MobileCapabilityType.APP_PACKAGE, APP_PACKAGE); cap.setCapability(MobileCapabilityType.APP_ACTIVITY, APP_ACTIVITY); cap.setCapability("device-orientation", "landscape"); cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100"); driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);

Any advice?
Thanks in advance

webview context appears only when if developer build the app with setWebViewDebugger flag as enabled while building the app.

1 Like

Thanks for your help.

Actually I created a new app which host webView with WebView.setWebContentsDebuggingEnabled(true); instead using native Chrome app.