Multiple Android Device Automation with Python

We’d like to scale out our automation infrastructure and I’m encountering errors in setting up multiple appium tests.

First, create one appium server per adb device with a unique port, bootstrap port, and unique device ID. Appium is started as in the following examples.

node /usr/local/bin/appium --debug-log-spacing -p 4723 -bp 4755 --automation-name Appium --platform-name Android --platform-version 7.0 --app ../Downloads/app-staging.apk --app-pkg com.app.staging --app-activity com.app.welcome.view.WelcomeActivity --app-wait-package com.app.staging --device-name emulator-5556 -U emulator-5556
node /usr/local/bin/appium --debug-log-spacing -p 4724 -bp 4756 --automation-name Appium --platform-name Android --platform-version 6.0 --app ../Downloads/app-staging.apk --app-pkg com.app.staging --app-activity com.app.welcome.view.WelcomeActivity --app-wait-package com.app.staging --device-name emulator-5554 -U emulator-5554

Following server creation, multiple web drivers are instantiated

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = OS
desired_caps['deviceName'] = str(serial)
desired_caps['app'] = PATH('../Downloads/app-staging.apk')

webdriver.Remote('http://localhost:' + str(port) +'/wd/hub', desired_caps)

The first remote webdriver is created without issue, but a timeout occurs in setting up the second. This occurs with both physical and emulated devices.

[HTTP] <-- POST /wd/hub/session 200 5048 ms - 988 
[BaseDriver] Shutting down because we waited 60 seconds for a command
[debug] [AndroidDriver] Shutting down Android driver
[Appium] Closing session, cause was 'New Command Timeout of 60 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability'
1 Like