Testing Hybrid Applications on Android

Hybrid applications (apps) are apps that are run on the device, like native applications, but are written with web technologies, for example HTML5, CSS, and JavaScript.

Silk4NET provides full browser support for testing debug hybrid apps that consist of a single web view, which is embedded in a native container. A common example of such a hybrid app would be an Apache Cordova application.

To prepare a non-debug hybrid app for testing, enable remote debugging in the app by adding the following code to the app:
WebView.setWebContentsDebuggingEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
To test non-debug hybrid apps without remote debugging enabled or hybrid apps that include more than one web view, enable the Silk4NET fallback support by setting the option OPT_ENABLE_MOBILE_WEBVIEW_FALLBACK_SUPPORT to TRUE. For additional information, see Setting Advanced Options. With the fallback support enabled, Silk4NET recognizes and handles the controls in a web view as native mobile controls instead of browser controls. For example, the following code clicks on a link when using browser support:
' VB .NET code
Agent.SetOption(Options.EnableMobileWebviewFallbackSupport, False)
_desktop.DomLink("//BrowserApplication//BrowserWindow//INPUT[@id='email']").Click()
// C# code
Agent.SetOption(Options.EnableMobileWebviewFallbackSupport, False);
_desktop.DomLink("//BrowserApplication//BrowserWindow//INPUT[@id='email']").Click();
With the fallback support enabled, the following code clicks on the same link:
' VB .NET code
Agent.SetOption(Options.EnableMobileWebviewFallbackSupport, True)
_desktop.Find("//BrowserApplication//BrowserWindow//MobileTextField[@resource-id='email']").Click()
// C# code
Agent.SetOption(Options.EnableMobileWebviewFallbackSupport, True);
_desktop.Find("//BrowserApplication//BrowserWindow//MobileTextField[@resource-id='email']").Click();
Silk4NET can detect web views that support Chrome remote debugging. Silk4NET can detect web views with either the package com.android.webview or the package com.google.android.webview, which are the default packages on most Android devices.
Note: Silk4NET supports testing hybrid apps on Android 4.4 or later. To test hybrid apps on Android, Android System WebView version 51 or later is required.

The process for testing a hybrid app on Android is the same as the process for testing a mobile native application. For additional information, see Testing Mobile Applications on Android.