2.1 Android real machine connection¶
using AirtestIDE to make automated testing for android applications,the first step is to connect to an Android device.
Android real machine connection's preparation:
- Please install the official driver of the corresponding brand of the mobile phone first, and make sure that the computer can be used for USB debugging.
- Make sure the "Developer Options" in your phone is open and open "Allow USB debugging" in "Developer Options"
- Some phones need to open "Allow emulation location", "Allow installation via USB"
- Turn off the mobile assistant software installed on the computer which can avoid most problems, please be sure to manually end the mobile assistant process in the task manager
1. Connect to Android real machine using USB¶
- Please use the USB cable to connect to the phone. When the
Allow USB debuggingpopup appears on the phone, click
- Click on the
refresh ADBbutton in the connection panel and the device list will be refreshed.
- Click the
Connectof the corresponding device in the list to complete the connection.
- If the device is not flashed, click the
If you are experiencing connectivity issues, please check out Android Connection FAQ.
2. Remote Connection¶
- If we know the IP and port
ip:portof the remote device, we can connect directly with AirtestIDE.
- Click the
Remote Device Connectionbutton in the device window.
- Fill the
adb connect ip:portfield with the fill box and click the
- The remote device will appear in the device list and click the
3. Wireless connections¶
- Reference: Use adb wireless connection phone
When the phone and the computer are on the same wifi, you can try to connect to the phone wirelessly.However, this method is limited by the stability of the network connection, and the connection may not be stable enough.The specific connection steps are as follows:
- Make sure the phone has the USB debugging option enabled and connect the phone to the computer with a USB cable.
- Execute the command
adb tcpip 5555on the computer side, where
5555is the port number, which can be specified according to your own needs,and 5555 is the default value.
- Get the IP address of your phone, which can be found in Phone Settings - About Phone - Status Information - IP Address, or you can run
adb ifconfigto view
- Then you can unplug the USB cable,enter
adb connect phone ip: the port number 5555 just filled inat AirtestIDE's
Remote Device Connection. Click on the connection button, then refresh the ADB and you will see the connected device in the device list.
- If the connection is disconnected due to network fluctuations, ADB restart, etc., re-execute
adb connect ip:port.
4. Connect in script code¶
If you need to connect your phone device in your code, please refer to the document How to connect to the phone/windows window.
Android string code for remote connections:
If you need to fill in the
Android:/// string when the code/script is running, and you don't know how to fill in the remote connected phone, you can run the script directly with AirtestIDE.Then copy the
Android:/// string generated by the IDE.
Usually, the string needs to be filled in as
Android://adbhost:adbport/serialno .Among them, adbhost and adbport are generally native adb by default, which is
127.0.0.1:5037.The difference between a remote phone and a local phone is the device number serialno:
Therefore, the actual device string of the remotely connected mobile phone in this picture is
Android://127.0.0.1:5037/10.254.60.1:5555, and you can see that
10.254.60.1:5555 actually represents the device number, so do not mistakenly fill in as adbhost.