Today, let's talk about it. If the automation implementation runs the script on more than one device.
First, we recall how to run a Python script on a single device, generally divided into three steps
1. Start Appium Service
2. Create a Driver
3. Run the Python script
Similarly, running more than one device is basically the three steps
1. Start multiple Appium services (by setting up different ports and associating devices)
2. Create the driver and ensure the port number and device association, and consistent with step 1
3, multi-threaded or multi-process run script.
Ii. decomposition of steps
Let's look at how these three steps are implemented in each of these
1. Start multiple Appium services, "Appium-p appium_port -bp bootstrap_port -u devicename --no-reset --session-override "
Need to solve the following problems
1) How to run DOS commands in Python
2) How to get the device
3) How to create an available port (non-occupied)
2, create the driver, the difficulty is that the drive needs to be created and the services in step 1 to correlate to ensure that the port, device, driver one by one corresponds
Solution Ideas
1) The variables (appium_port, bootstrap_port , and devicename) are written to the file at the same time as the command is generated by step 1, which can be the init file, Yaml file or other)
2) When creating the driver, read the port and device name from the file,
3. Multi-threaded or multi-process run scripts
Practice finds that using multithreading to run Python scripts, under the latest Appium service, can sometimes cause confusion, in order to avoid this problem, we use multiple processes here.
Iii. Summary of Ideas
1. Execute dos in Python, get device information, create an available port
2. Execute DOS command to start multiple Appium services
3. Write the Boot information (ports and devices) to the Yaml file
4. Read the port number and device information from the Yaml file and create the corresponding driver
5, introduce multi-process, run the script
Appium Automated Testing Framework--automated start-up of multiple equipment thinking carding