Hello everyone, I’m IT sharer, also known as Pipi. The first article talked about the Airtest installation and IDE control details of the relevant knowledge, mobile phone automatic test IDE—–Airtest basic operation method, mobile phone automatic test IDE—–Airtest installation and IDE control details, This article is to share with you the use of Airtest simulator to connect to mobile phones.

preface

Perhaps some people feel that it is difficult to capture the data packet of the phone, but also what automation, and certainly not easy. But I have to tell you that this is all done by an automated testing software called Airtest. You just have to keep it running and do everything on your phone.

Connected devices

1. Connect the simulator phone to Airtest

Here we need to connect the mobile phone. Since xiaobian has a simulator, in order not to affect xiaobian’s mobile phone playing, I decide to use Airtest simulator to connect the mobile phone, open the simulator, and select about tablet computer, as shown in the picture:

Click the version number several times until the Developer option feature appears, and then open the USB debug under Developer Option, as shown in the figure below:

Now we have started USB debugging. Let’s Airtest to connect our emulator remotely, as shown in the figure below:

Here is one knowledge to explain to you is that the remote port number we connect is not arbitrary, but different port number according to the emulator. The one-to-one relationship between the emulator and the port number is as follows:

After selecting our host address and port number, we can connect. Then we can click Connect to connect directly, as shown in the picture:

Since we are using the simulator connection, the first item on the picture had better be selected, otherwise the simulator will not have a picture even if it is connected. If the screen capture program Yosemite. Apk was not downloaded to the emulator, drag it to the emulator, connect to the emulator again, and open it, as shown below:

I made a successful connection. Here is a brief description of the above three options:

Use ADB Orientation: use ADB Touch: use ADB Touch: use ADB TouchCopy the code

2. Connect to the WIndows desktop application

Here we can not only connect to the emulator, but also connect to the application we have opened or not opened. We can click on the selected window, select the specified application, and then the program will be loaded into Airtest. Here I open 360 browser, as shown in the picture:

Can see be loaded in, we can browse in the back, but at the moment our desktop browser is missing, this is because Airtest are using our browser, when we click disconnect current device can shut off the device, the browser will be able to see again returned to our desktop, as shown in figure:

2. Connect the real Android to Airtest

Although the simulator is very convenient, it is very troublesome after all, and if your computer configuration is not good, the simulator may explode after only a few applications are opened. Therefore, we also need to use the mobile phone to connect to Airtest. Compared with other connection methods, the mobile phone is a little more complicated.

1). Set developer related options

First we need to plug the data cable into the USB port of the computer, and then open the developer option and USB debugging again. In addition to setting the above options, we also need to set the default USB configuration and set it to MIDI. The default USB configuration is right below USB debugging, as shown in the figure below:

Then select MIDI as shown:

That’s the end of all the developer options on the mobile side, but it’s not enough, you still need a lot of action, yes, yes, a lot of action, and that’s the biggest problem with the IDE.

2). Install phone-related drivers

Because xiaobian mobile phone is Vivo, so xiaobian on the Internet under a Vivo driver package, if your phone is not a version with xiaobian, then please see the following:

Millet: samsung, huawei: http://www.samsung.com/cn/support/downloads http://consumer.huawei.com/minisite/HiSuite_cn/ http://bigota.d.miui.com/tools/xiaomi_usb_driver.rar Vivo: One plus: http://zs.vivo.com.cn/download.php meizu: http://care.meizu.com/ http://service.oneplus.cn/ asus: Lenovo: http://www.asus.com.cn/support/ http://www.lenovocare.com.cn/default.aspx LG: MOTOROLA, SONY: http://www.lg.com/us/support/software-firmware-drivers https://developer.sony.com/develop/drivers/ HTC: https://mobilesupport.lenovo.com/us/en/solution/MS88481 http://www.htc.com/us/software/htc-sync-manager/ Google: The blackberry: https://developer.android.com/studio/run/win-usb.html Dale: https://swdownloads.blackberry.com/Downloads/entry.do?code=4EE0932F46276313B51570F46266A608 Acer: http://www.dell.com/support/home/us/en/04/Products?app=drivers&lwp=rt https://www.acer.com/ac/en/US/content/driversCopy the code

If it still doesn’t exist, you’ll probably need a driver that works with all devices, either the life driver or the Sprite driver, whichever you choose.

3). Configure the input method and simulation position

If you want to type text in the Airtest, you can’t do it using your phone’s built-in input method. You have to use Yosemite, which is automatically downloaded to your phone after you install the driver. As shown in figure:

Then we can set the system default input method to this one, as shown in the figure below:

Although we can enter the text after setting up, sometimes the mouse click may not be very accurate, so at this time, we also need to set the simulation position, also in the developer option, as shown in the picture:

After this setting, we can return to the main screen of our Airtest, we can see the name and status of the device has appeared, as shown in the picture:

4). Connect the device

Just like the emulator, click Connect to check Use Javacap, then the device has been successfully connected, as shown in the picture:

5). Wireless connection to Android real machine

Here we do not need to prepare data cable can also connect to our Android machine, as long as you complete the three steps, it is simple. We first need to know the IP address of the android real machine, which can be viewed here, as shown in the picture:

We then use this IP address to establish a connection in Airtest, as shown below:

Note that the port number here is 5555. This works if you write other ports, but it does not listen for TCP/IP information. If you want to specify more than one port, type the following command at the command prompt:

Adb tcpip 666# enable port 666Copy the code

There is a premise, is that the mobile phone and our IDE must be in the same Wifi network environment, otherwise it is not accessible.

6). Use script connections

Here we double click the script editing window and set up an editor script file as follows:

After setting, you can see the following screen when you return:

Then we can connect android in this, the specific code is as follows:

Connect_device (' Android: / / 127.0.0.1:5037 / mobile IP address: 5555 ') # is in front of the number and the IP address of the port is your mobile phone behindCopy the code

Please note that the android device and IDE also need to be in the same WiFi network environment.

conclusion

Today we are talking about the installation of this automatic tool and the analysis of interface functions, this tool as a whole, the usage is relatively simple, is too much installation pit, novice xiao Bai may take some time to understand, in this special share with you, wish you to learn the road more smooth and smooth. Next time, we’ll talk about IDE.