I. Android Real Device Connection¶
When using AirtestIDE for automated testing of Android applications, the first step is to connect an Android device.
Preparation for Android Real Device Connection:
- Please install the official corresponding driver of the phone brand, to ensure that you can use USB debugging on your phone with your computer.
- Make sure that the "Developer Options" have been enabled on your phone and that "USB debugging" is turned on within the "Developer Options".
- Some phones may require enabling settings such as "mock locations" and "installation of apps via USB".
- By disabling the mobile assistant software installed on the computer can avoid most problems. Please be sure to manually remove the mobile assistant from the task manager.
1.Android Real Device Connection via USB¶
- Please use a USB cable to connect your phone to the computer. When the "Enable USB debugging" pop-up appears on your phone, click on OK.
- Click on the refresh ADB button in the connection panel, and the device list will be updated.
- Click on Connect on the corresponding device in the list to complete the connection.
- If the device is not detected, click on the restart ADB button.
If you encounter any problems in your connection process, please refer to Android Connection FAQ.
2.Remote Connection¶
- Given the IP and port of the remote device ip:port, AirtestIDE can directly connect to the device. - Click on the Remote Device Connection button on the device screen panel. - Fill in the "adb connect ip:port" in the input box and click on the connect button. - The remote device will appear in the device list, then click on the connect button.
3.Wireless Connection¶
- Reference: Using ADB to Wirelessly Connect to Phones.
When the phone and computer are under the same WiFi network, you can try to connect the phone wirelessly. However, this method is subject to the stability of the network connection, and unstable connections may occur. The specific steps for connecting are as follows: 1) Make sure that USB debugging is enabled on the phone and connect it to the computer with a USB cable. 2) Execute the command "adb tcpip 5555" on the computer, where 5555 is the default port number that can be specified according to your own needs. 3) Obtain the IP address of the mobile phone. You can find it in Settings>About Phone>Status Information>IP Address, or you can execute "adb ifconfig" to find it. 4) Afterwards, you can unplug the USB cable. In AirtestIDE's Remote Device Connection, input adb connect phone IP: the port number 5555 you just filled in, click on the connect button. After refreshing ADB, you can see the connected device in the device list. 5) If the connection is interrupted due to network fluctuations, restarting ADB, or other reasons, execute adb connect ip:port again to reconnect. Note: When using wireless connection, you still need to connect your phone and computer with a USB cable at the beginning, and never unplug it before specifying the port and querying the IP!!!
4.Real Android Device Connection via the Code¶
If you need to connect a mobile device in the code, please refer to Introduction to the Airtest Scripts for Connecting Devices. Android string code for remote connection: If you need to fill in the string code of Android:/// in the code or script but are unsure of how to fill it in for a remotely connected phone, you can simply run the script once in AirtestIDE and then copy the Android:/// string code generated by the IDE. Usually, the content of the string is "Android://adbhost:adbport/serialno". In general, adbhost and adbport are both set to the local adb by default, which is 127.0.0.1:5037. The only difference between connecting a local device and a remote device is the serialno. Therefore, the device string code for the remotely connected phone in the picture is actually "Android://127.0.0.1:5037/10.254.60.1:5555". Among them, 10.254.60.1:5555 is actually the serialno, so don't mistake it for adbhost.