Prepare Android test automation

To perform Android test automation with the Mobile Engine 3.0, you have to first prepare the device or emulator, the computer, and the mobile application.

Follow the instructions in this chapter to perform these actions:

Additionally, for local Android devices, you need a USB cable and a USB driver to connect the device to a computer with Tricentis Tosca or a Mac.

For detailed information on installing drivers for Samsung devices, refer to the Tricentis Knowledge Base.

For detailed information regarding software versions and hardware requirements for Android test automation with the Mobile Engine 3.0, refer to the System Requirements.

Prepare Windows for Android test automation

To prepare the operating system for Android test automation, follow these steps:

  1. Use a computer with Tricentis Tosca on it.

  2. Ensure you've installed the Mobile Engine 3.0 components.

  3. Install Tricentis Mobile Agent.

  4. Connect your Android device to your PC via a USB or connect an emulator.

Prepare Android devices or emulators for test automation

Follow the instructions below to perform these actions:

The specific location of settings and options may vary depending on your device.

Prepare Android devices for test automation

To prepare an Android device for test automation, follow the steps below:

  1. Connect your Android device to your computer via a USB.

  2. On the Android device, allow access to phone data.

  3. Go to Settings->Developer options and select USB debugging.

  4. Optionally, select Stay awake to keep the screen on while you run your tests.

  5. Ensure that the USB Driver for the device is installed on the computer.

    For detailed information on installing the USB Driver, refer to the Tricentis Knowledge Base.

  6. Open Tosca Commander and prepare your TestCases:

Prepare Android emulators for test automation

To prepare an Android emulator for test automation, follow the steps below:

  1. Install and set up a valid Android emulator on the computer where you want to run your TestCases in Tosca Commander.

    For detailed information on how to set up an Android emulator, refer to the Android Developer website.

  1. Open the Android emulator.

  2. Open Tosca Commander and prepare your TestCases:

Prepare Android hybrid applications for test automation

To prepare Android hybrid applications for test automation, you have to modify them in your IDE (Android Studio/IDEA). To do so, add the following settings:

The mobile application under test has to be signed with a developer certificate.

Add WebView settings

To steer hybrid applications, you have to enable the communication between Tricentis Tosca and the application's web-based elements. To do so, go to the fragment or activity used to set up your WebView and add the following settings:

Copy
myWebView = (WebView) findViewById(R.id.webview)
myWebView.getSettings().setJavaScriptEnabled(true)
myWebView.setWebViewClient(new WebViewClient())
myWebView.setWebChromeClient(new WebChromeClient())

Add WebView settings

These settings perform the following actions:

  • They find the webview.

  • They enable JavaScript, which makes it possible to communicate with the webview.

  • They create webview clients used for communication with Tricentis Tosca.

Enable web content debugging

To steer hybrid applications, you have to enable web content debugging. To do so, go to the onCreate method and add:

Copy
WebView.setWebContentsDebuggingEnabled(true)

onCreate method

Prepare test automation on Android version 10 or later

If you use a mobile device with Android version 10 or later and your mobile application has a target SDK version 23 or lower (Android 6.0), an additional Permissions pop-up window appears before your application starts. This affects your tests.

Proceed with one of the following actions:

  • Update the targetSdkVersion and apply the Desired Capability appium:autoGrantPermissions with the value True. We recommend that you choose this option.

  • Automate the Continue button on the Permissions pop-up window with a separate TestStep.

Recommendations for Xamarin applications

With the Mobile Engine 3.0, you can steer applications created with the Xamarin framework. You can use all standard mobile web controls and native controls. This chapter provides information on optimizing Xamarin applications for testing with the Mobile Engine 3.0.

ID Handling of controls

To improve the preciseness of testing, consider the following:

  • On Xamarin Forms: ensure to fill the optional AutomationId parameter. Tricentis Tosca recognizes this parameter as Content Description during scanning, and can use it as the unique ID required for steering the control.

  • On Xamarin Android: ensure to set the ContentDescription parameter. Tosca recognizes this parameter as Content Description during scanning, and can use it as the unique ID for steering the control.