Inconsistent Access to WebView Contexts in Android App

I’m in the process of automating various test cases using C# (net6.0), and Appium (v5.0.0). I’ve run into some issues with this that has me investigating how the Capacitor app configures the WebView.

When I start an Appium session for our Android build (using the UiAutomator2 driver if it matters) I find that the availble CONTEXTS are extremely inconistant. Some times, there will be both and WEBVIEW_chrome in addition to the NATIVE_APP context. However, other times there will only be NATIVE_APP.

In my research, I found that Appium will sometimes have issues with context switching when fields “url” & “title” are empty for the WebView target. Natively in Android, you can set these fields fairly easily in a WebView. How are these fields set for a WebView in a Capacitor app?

We are using:

  • Node Version: 14.19.1
  • NPM: 6.14.16
  • @ionic/react: ^6.0.9
    And our capacitor.config.json file contains the following for android:
        "useLegacyBridge": true,
        "appendUserAgent": "android:application",
        "webContentsDebuggingEnabled": true

This question might be a better fit for the Capacitor forum because Ionic React sits on top of Capacitor and it seems that Capacitor is the cause of the issue here.