Mobile Development 5 min read

Parallel Multi‑Device Testing with Appium: Dynamic Desired Caps, Multi‑Process Services, and Port Management

This article explains how to set up a Windows environment with Node.js, Python, and Appium, dynamically generate desired capabilities for multiple phones, launch parallel Appium services and tests using multi‑process techniques, and handle port detection and release to achieve efficient multi‑device automation.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
Parallel Multi‑Device Testing with Appium: Dynamic Desired Caps, Multi‑Process Services, and Port Management

The article begins by describing the need for automated multi‑device testing to avoid time‑consuming manual checks across many smartphones.

Installation Environment

Required tools on Windows include Node.js, Python, Appium, the Appium‑Python‑Client, JDK, Android SDK, and appium‑doctor.

1. Appium Configuration

A YAML file is created to list common parameters; these values are later modified dynamically based on each device's specifications.

Initialization of Appium is performed through a method that receives device‑specific parameters at runtime.

2. Multi‑Process Launch of Multiple Phones

The script first detects the number of connected devices, extracts their OS version, name, and unique ID into a PhoneInfo class, and builds a list. For each device, a separate process is spawned.

Port numbers are incremented per device (e.g., 4725, 4727, 4729 for three phones), and the device‑specific parameters are passed to match each process with its corresponding phone.

3. Multi‑Process Launch of Multiple Services

Appium’s default server port is 4723; to run several services, the port is increased for each instance. The command to start a service is:

appium -a 127.0.0.1 -p 4723 --bootstrap-port 4724

A helper method wraps this command for single‑process service startup, and a multi‑process version iterates based on the detected device count.

4. Port Detection and Release

Port availability is checked by attempting a socket connection; a successful connection means the port is occupied, while a failure indicates it is free for launching an Appium service.

To release ports, a command (shown in the original images) kills all running Appium processes.

5. Start Multi‑Process Tests

With services and devices prepared, the script launches parallel test execution across all devices, achieving efficient, automated testing.

pythonautomationMobile TestingappiumParallel ExecutionMulti-Device
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.