Skip to content

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

image

  • Please use the USB cable to connect to the phone. When the Allow USB debugging popup appears on the phone, click OK.
  • Click on the refresh ADB button in the connection panel and the device list will be refreshed.
  • Click the Connect of the corresponding device in the list to complete the connection.
  • If the device is not flashed, click the refresh ADB button.

If you are experiencing connectivity issues, please check out Android Connection FAQ.

2. Remote Connection

image

  • If we know the IP and port ip:port of the remote device, we can connect directly with AirtestIDE.
  • Click the Remote Device Connection button in the device window.
  • Fill the adb connect ip:port field with the fill box and click the Connect button.
  • The remote device will appear in the device list and click the connect button.

3. Wireless connections

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:

  1. Make sure the phone has the USB debugging option enabled and connect the phone to the computer with a USB cable.
  2. Execute the command adb tcpip 5555 on the computer side, where 5555 is the port number, which can be specified according to your own needs,and 5555 is the default value.
  3. 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 ifconfig to view
  4. Then you can unplug the USB cable,enter adb connect phone ip: the port number 5555 just filled in at 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.
  5. If the connection is disconnected due to network fluctuations, ADB restart, etc., re-execute adb connect ip:port.

image

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:

image

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.