Parallel Devices Automation
Executing automated tests in parallel is dependent on any of the following:
- App supports parallel sessions
- Test Automation Framework can initiate parallel tests
- Multiple appium servers - one for each device and has dedicated ports
Parallel execution also might result in race conditions, so understanding the application domain and call path is extremely important before we certify parallel tests.
Start Appium servers on different ports
Command to start multiple appium servers. Open a new shell for each of the below appium servers.
appium -p 4724 -bp 4726 -U EGxxxxxxxxx
appium -p 4734 -bp 4736 -U EGxxxxxxxxx
Note: If your target device/emulator has sdk < 4.2 or API level < 16 , appium used selendroid, hence you have to append --selendroid-port to the command above(generally stay 10 ports apart, because appium uses +1 port of -p):
appium -p 4724 -bp 4726 --selendroid-port 4737 -U EGxxxxxxxxx
appium -p 4734 -bp 4736 --selendroid-port 4747 -U EGxxxxxxxxx
If you are running appium from (Appium.exe) path then , node appium --nodeconfig path\to\nodeconfig.json -p 4724 -bp 5724 (or) if you're doing from cmd, appium --nodeconfig path\to\nodeconfig1.json -p 4724 -bp 5724
Client Side
We mean the test automation framework code that can connect to the Appium servers here. Write logic to instantiate the driver session based on the available pool of devices/emulators. In this case, you would have to parse the devices.yaml or emulators.yaml and create $driver session by connecting the corresponding port.
Selenium GRID
While appium_lib gets you started by wrapping up the underlying Selenium commands, if you intend to maintain a on-premise mobile lab, then creating an instance of RemoteWebDriver is a better approach. That way, we deal only with the Selenium libraries and appium server becomes a webdriver server like chromedriver or IEDriverServer binaries.