APPIUM control multiple Android devices to automate testing

A. Setting APPIUM server

1. Open APPIUM, click on the 'Advanced';

Here Insert Picture Description
2. to set certain rules 'Sever Port', 'Bootstrap Port' (My personal rule is incremented by 1 in accordance with, convenient), began a two APPIUM occupied port number, followed by an increase, which is for the convenience of writing code behind automatically connect APPIUM port, and then click on 'Save As Presets', and then will let you pop name, the name of the operation did not affect you in the future, may be blind ** name, do not repeat on the line;

Here Insert Picture Description
Here Insert Picture Description

3. After you set up several default port, click on the 'Presets', select the default value of the port you want to start, click on the 'Start Server V1.13.0', which started a APPIUM, and later you can according to their need to control several Android phones automated testing, open a few APPIUM.

Here Insert Picture Description

II. Code Parameter Setting

1. Set the parameters of the code is the most important ideas pulled out all the variables, as shown my setup, 'platform_version' Andrews version, 'device_name' is the device name, 'app_package' is measured APP package name, 'app_activity' APP is measured start of the name, 'device_index' I is connected to the control code APPIUM server port used.

Here Insert Picture Description

III. Automatically get parameter variables

1. Get all Android mobile devices connected to the computer's name (the phone must be in developer mode, and turn on USB debugging mode), the implementation of ADB commands use subprocess.Popen call cmd, and then return the data to process, and ultimately return a dress there list all device names. Note that I wrote in the windows system code, if you are in linux like system, code needs to be adjusted.

Here Insert Picture Description

2. Get the device name list corresponding to the list of Android version, and a method for acquiring equipment almost, but it is the premise of the acquired equipment list, the device list as a parameter pass in must come out;

Here Insert Picture Description

3. Get the package name and start the APP name, we want to test generally APP is fixed, if it can find its products directly to the development package, activity, if it is other people's products, it can open the app, and then cmd above enter the following command (the case of connecting only one Android device, multiple devices to add -s device name), and FIG beginning of com '/' on the left is the package name, the name of the right is started, it is noted that , under normal circumstances because of the different names start you are in the interface is different, generally you have to locate the interface for the first time after the start; of course there are other ADB command to precisely locate the name of the startup, do not start here go into detail .

// An highlighted block
adb shell dumpsys window windows | findstr "Current"

Here Insert Picture Description

IV. The use of multiple processes running code

According to the number of connected devices, generate a corresponding number of processes to deal with, I am not here PO code, especially if you need to, then the message board CALL me, when I come again PO.

Released four original articles · won praise 0 · Views 490

Guess you like

Origin blog.csdn.net/weixin_42579304/article/details/100555762