Connecting TestExecute to Android Devices

Applies to TestExecute 14.72, last modified on January 12, 2021

Before you start testing Android applications, you need to make sure they are accessible to TestExecute. TestExecute works with Android devices via Android Debug Bridge (ADB). Therefore, connect ADB to your Android device or virtual machine to make them accessible to TestExecute.

Note: If you are using an Android device emulator, there is no need to connect ADB to it. Run the emulator and TestExecute will access it automatically.

Connecting Physical Devices

1. Prepare Device and TestExecute

Make sure your mobile device has been prepared for testing. Remember to enable the developer settings on the device and install device drivers on your computer if necessary. See Preparing Physical Android Devices for Testing.

Make sure you have installed Android SDK on your computer and specified the path to it in TestExecute settings.

2. Connect the Device

You can connect a physical device via USB or Wi-Fi:

USB

Turn on your device and connect it to your computer with a USB cable. Android Debug Bridge will detect the connection and will automatically connect to the device.

Wi-Fi

By default, the debug service on a device is configured to work via USB. You need to configure it to accept commands via TCP/IP:

  1. Turn on your device, enable Wi-Fi on it and connect the device to your local network via Wi-Fi.

  2. Explore Wi-Fi settings on the device to find out the device IP address. Write down or remember the device IP address.

    The actual search steps to perform depend on your device and the Android version it has. Typically, you open Wi-Fi settings on the device and tap the Wi-Fi connection that you set up – Android will display the connection details including the IP address your device got. For more information, please see documentation on your device and Android version.

  3. Important: Connect your device to your computer via USB cable.

  4. On your computer, press Win+R to open the Run dialog, and then type cmd and press Enter to open the Windows command prompt.

    Run the following command in the command prompt. Make sure to replace <Android SDK> with the path to Android SDK on your computer:

    <Android SDK>\platform-tools\adb  tcpip  port-number

    This command tells the debug service on your device to listen to debug commands on the specified TCP port. You can enter any port that is free on your device, but we would recommend using default port 5555.

    Note: The example above implies that you have only one device connected to your computer via USB. If you have multiple devices, you need to specify the device for the adb tcpip command.

    See details

    More information on this is available in Android documentation (https://developer.android.com/studio/command-line/adb.html#directingcommands).

  5. In the command prompt, run the adb connect command to connect to your device:

    <Android SDK>\platform-tools\adb  connect your-device-IP:port

    For example:

    c:\android-sdk\platform-tools\adb connect 192.168.0.34:5555

  6. Important: After ADB connects to your device via Wi-Fi, disconnect the USB cable. If you keep the cable plugged in, ADB will recognize two devices instead of one, which may cause errors during testing.

    Also, it is important that you plug the device in to a power outlet. This will prevent accumulator discharge and screen blackout during testing. (Despite the fact you enabled the Stay awake option on your device that disables screen blackout, many Android systems ignore this option if there is no USB connection).

When do I need to repeat these steps? Repeat them every time the connection between the device and the Debug Bridge running on your computer is lost. For example, after you reboot your computer, or after you stop the ADB service running on it, after your device loses the Wi-Fi connection to your network, and so on.

Note: Some devices may require a restart to switch from the Wi-Fi mode back to the USB one.

Connecting Virtual Machines

1. Prepare Virtual Machine and TestExecute

Make sure your Android virtual machine has been prepared for testing. Make sure it is available in your local network and accessible for TestExecute. See Preparing Android Virtual Machines for Testing.

Make sure Android SDK is installed on the TestExecute computer, and its path is specified in the TestExecute settings (see Android Options Dialog).

Do not run TestExecute and TestComplete at the same time on the same computer to avoid Android device access errors.

2. Get the IP Address of the Virtual Machine

  1. Start your virtual machine and wait until Android is loaded.

  2. In the virtual machine screen, press Alt+F1. This will open the console.

  3. Type netcfg in the command line. This will display network addresses assigned to your virtual machine. For example:

           A N D R O I D root@x86:/ # netcfg
    ip6tn10  DOWN                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
    sit0     DOWN                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
    eth0     UP              192.168.56.101/24  0x00001043 08:00:27:eb:38:d9
    lo       UP                   127.0.0.1/8   0x00000049 00:00:00:00:00:00
    root@x86:/ # _

  4. Copy or write down the IP address (in the example above it is 192.168.56.101).

    Press Alt+F7 to return back to the graphic mode if necessary.

3. Connect the Android Debug Bridge to the Virtual Machine

  1. On your computer, press Win+R to open the Run dialog.

  2. In the Run dialog, type cmd and press Enter. This will open Windows command prompt.

  3. Enter the following command in the command prompt and press Enter. Make sure to replace <Android SDK> with the path to Android SDK on your computer and specify the actual IP address of your virtual machine that you got on the previous step.

    <Android SDK>\platform-tools\adb connect 192.168.56.101

Now the virtual machine is connected to Android Debug Bridge and TestExecute.

Highlight search results