This topic describes the preliminary actions you need to perform to prepare the environment for testing Android applications with TestComplete.
Note: | With TestComplete, you can test applications that are running on physical mobile devices (smartphones and tablets), emulators, and Android-x86 virtual machines.
For the full list of supported and non-supported devices, see About Testing Android Applications. In this section, we will provide instructions on preparing for testing on a physical device. Preparatory actions for Android emulators and Android-x86 virtual machines are different (see Preparing Devices, Emulators and Virtual Machines). With this exception, the rest of the testing actions are performed in the same manner. |
The topic contains the following sections:
Installing Required Software
Installing JDK and Android SDK
To test Android applications, you need to download and install Java Development Kit or Java Runtime Environment (JDK or JRE) ver. 6 - 8 and Android SDK on your test computer.
Notes:
- Testing Android applications by using Java SE Runtime Environment (JRE) or Java SE Development Kit (JDK) ver. 9 - 11 is not supported currently.
-
If you already have the Android SDK and JDK (or JRE), install the needed platform and build tools via the SDK Manager or the sdkmanager utility as described below.
-
Download the JDK from:
http://java.com/en/download/windows_manual.jsp
For testing, it is enough to have JRE installed, but you may need to download and install JDK, as JDK includes JRE modules.
-
Run the downloaded installation and follow the instructions in the wizard.
-
Download the Android SDK from:
https://developer.android.com/sdk/index.html
You can download it as part of Android Studio (the default download), or you can download the SDK only.
To get Android Studio
-
On the Download page, click Download Android Studio.
-
Run the downloaded installation and follow the wizard instructions.
-
After the studio is installed, launch it and select Configure > SDK Manager.
- In the SDK Manager, make sure that the following items are selected:
The SDK Platforms tab
- Android 10.x
The SDK Tools tab
-
Android SDK Platform-tools
-
Android SDK Build-tools ver. 26.0.2 or later
-
Google USB Driver
-
Click OK to install packages if needed. Accept the license agreement and proceed with the installation.
To get the SDK only
-
On the Download page, scroll to the Get just the command line tools section and download the sdk-tools-windows-NNN.zip package.
-
Extract the files and locate the sdkmanager utility.
- Use the utility to install the following items:
-
Android 10.x (on the SDK Platforms tab)
-
Android SDK Platform-tools
-
Android SDK Build-tools ver. 26.0.2 or later
-
Google USB Driver
To do this, run the utility with the following command-line parameters:
sdkmanager "platform-tools" "build-tools;NN.N.N" "extras;google;usb_driver"Where NN is the version of the API for which you want to install the tools.
-
-
Installing Device USB Drivers
As stated above, in this tutorial we will automate tests on the physical device. In order to interact with the device, you need to install the device USB driver on the TestComplete computer. For instructions and driver download links, see OEM USB Drivers in Android documentation:
Installing and Configuring TestComplete Plugins
To be able to test Android applications, you must have a license for TestComplete Mobile module. This module includes the required plugins.
If the plugins is not available, you need to run the TestComplete installation program in the Modify mode. This will install and activate the required plugins.
Configuring TestComplete
Once the plugins are active, you may need to specify paths to JDK and Android SDK in TestComplete settings. The TestComplete installation wizard tries to find these paths automatically on your computer. If it is unable to do so, you may need to manually specify these paths in TestComplete.
To check whether the paths are specified correctly:
-
Launch TestComplete.
-
Select Tools > Options from the TestComplete main menu. This will open the Options dialog.
-
On the left of the dialog, select the Engines > Mobile > Android category.
-
In the Path to Android SDK edit box, specify the folder where you installed the Android SDK on your computer.
-
In the Path to Java Runtime edit box, specify the folder where Java is installed on your computer.
-
Switch to the Engines > Mobile > General category.
-
Enable the Automatically display Mobile Screen on OnScreen operation option.
-
Enable the Automatically display Mobile Screen when recording option.
-
Click OK to close the dialog and save the settings.
Preparing Mobile Device
After all of the required software was installed on the desktop computer, you need to prepare the mobile device as well.
Enabling Developer Options on the Device
To perform testing on a physical Android device, you need to enable certain developer options on the device:
-
Make the developer options visible. Go to Settings > About phone/tablet and touch Build number 7 times.
Note: The way in which you make the developer options visible may vary between devices and Android versions. Please, refer to the documentation on your device for more information. -
Go to Settings > Developer options and enable the following options:
-
USB debugging - Enables communication between the device and Android Debug Bridge (ADB). In other words, it makes your device visible to ADB and TestComplete.
-
Stay awake - Prevents the device from going into sleep mode during debugging.
For Xiaomi users: If your Xiaomi device has the USB Debugging (security settings) and Install via USB options, you must enable the options. To do this, you need an active Mi account, and a SIM card must be inserted into the device.
-
-
Save the changes.
Connecting the Device
Turn on your device and connect it to your computer with the USB cable. Android Debug Bridge will detect the connection and automatically connect to the device.
Checking Whether Device Is Connected
To verify whether the mobile device has connected successfully:
-
Click the Show Mobile Screen button on the TestComplete toolbar.
The Mobile Screen window will open if at least one mobile device or virtual machine is connected to Android Debug Bridge.
If you have several devices or virtual machines connected, a click on the Show Mobile Screen item will open the Select Current Device dialog that lists the connected devices. Check whether your device or virtual machine is on the list, select it there, and click OK to view its screen.
Now TestComplete and the mobile device are prepared for testing. In the following sections, we will describe how to create a test project, create a simple test, and play it back.
See Also
Testing Android Applications
Preparing for Testing Android Applications