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:

Prerequisites for Android test automation

Test automation on an Android device or emulator requires the following components:

  • Mobile Engine 3.0 components which are included in the Tricentis Tosca standard installation.

  • A computer with Tricentis Tosca on it.

  • If you want to perform mobile test automation via a Mac, you need Xcode, Java, and Appium installation on your Mac. For detailed information, see chapter "Prepare your Mac for mobile test automation".

  • An Android device or emulator.

  • 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 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 operating system for Android test automation

Follow the instructions below to:

Prepare Windows for Android test automation

If you connect your device to a PC that has Tricentis Tosca installed, ensure the Mobile Engine 3.0 components are installed.

If you connect your device to a PC that doesn't have Tricentis Tosca installed, follow these steps for Android test automation:

  1. Manually install Android Debug Bridge.

  2. Install and start the Appium Server version 1.16-beta1

    If you upgrade an older Appium Server version to 1.16-beta1 you might have to uninstall the Appium application Appium Settings from your device first.

  3. Connect your Android device to your PC via a USB.

Mobile Engine 3.0 starts the Appium Server automatically during scan and test execution. However, if you want to start the Appium Server manually, you have to define the ANDROID_HOME Environment Variable.

To do so, follow the steps below:

  1. Go to Windows Control Panel->System Properties->Advanced and click Environment Variables....

  2. Under User variables, click the New... button.

  3. In the Variable name box, enter ANDROID_HOME.

  4. In the Variable value box, enter %TBOX_HOME%\AndroidSDK.

  5. Click OK to add the variable and exit.

Prepare Android devices or emulators for test automation

Follow the instructions below to:

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, set the USB computer connection mode to PTP.

  3. Go to Settings->Developer options and enable the USB debugging option.

  4. Check if 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.

  5. Open Tosca Commander and prepare your TestCases:

  6. Run 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:

  3. Run your TestCases.

For Genymotion test automation you have to set the Android SDK path to the same one that Appium uses. In case of a local execution on Android, set the Android SDK path in Genymotion to %TBOX_HOME%\AndroidSDK.

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:

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: WebView.setWebContentsDebuggingEnabled(true).

Edit onCreate method

Prepare test automation on Android 10

Tricentis Tosca uses Appium 1.16-beta1 , which allows you to test applications on mobile devices with Android 10. Most applications don't require special preparation for test automation on Android 10.

However, if your mobile application has a target SDK version 23 or lower, 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 autoGrandPermissions with the value True.

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

Tricentis recommends that you use the first option.

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.