Implement Parallel Testing for Mobile device for appium

Hello,
I’m currently exploring parallel testing with Appium as well. I was wondering if you could guide me through the precise steps you’ve taken.

I’ve set up the server to start and stop programmatically, and all my capabilities are defined within a dedicated class.

I’d appreciate any insights that can provide regarding the involvement of capabilities, the instantiation of drivers in tests, and any other crucial details.

below is the details of the configuration used.

Testcase that runs looks like

public class login extends MasterTest1 {

@Test
public  voidLogin() throws IOException {

    AndroidDriver<AndroidElement> driver = Capabilities("androidapp");

/Code for Tests (I am using hash maps for the mappings
}

Thank you in advance.

Are you just going to run just 2 parallel tests? To me, if more than that you should take a serious look at Selenium Grid:

https://appiumpro.com/editions/54-using-appium-with-selenium-grid

1 Like

Should hardly. May better.

We used ONE macMini with 16 phones connected to it for 2 years. Now two macMinis with ios and android phones. Each 12-14 phones. While one macMini enough to handle 30 phones, we decided to use two - just in case. No grid.

But grid can give better benefit if you need manual QA access each phone remotedly and execute manually there anything

So at least two choices now :slight_smile:

Question for you. What kind of usb hub are you using for this? Do you need to use multiple hubs?

Hubs with power supply like

M2pro macMini i believe can hold easy 50 phones. Just need 32Gb ram machine. We did upgrade month ago one. 12 iphones running cause CPU usage about 10-15% while also running mpeg video of all phones. We record all tests. Even successful.

1 Like

Thank you, @wreed!

Currently, I’m working on implementing the solution on at least two devices. My initial strategy was to succeed with this configuration, and if successful, I planned to extend it to include a greater number of devices or emulators.
I appreciate your suggestion regarding Selenium Grid. I will delve into it more deeply. However, I was exploring alternative solutions that would allow me to bypass the grid and instead utilize TestNG parameterization or a similar approach.

I have successfully initiated an app on two emulators. However, a notable issue has arisen: only one test case executes as expected on device 2, while on device 1, after launching the app, nothing occurs. Upon reviewing the logs, I observed that when test case 2 on device 2 is running, test case 1 is also using device 2’s port, as defined in the properties file.

Key modifications made in the files to achieve this include:

  1. Utilizing @Parameters from TestNG, I defined a set of parameters (such as udid , platformname , and port number) inside the global properties file. These parameters are then read in the capabilities.
  2. Appium is automatically initiated using AppiumDriverLocalService .
    For detailed information, please refer to the attached Appium logs in the.

Additionally, the “Sample code(1).txt” file contains the code used for this implementation, including the MasterTest class, details of the global.properties file, and the TestNG file.
Sample code (1).txt (5.5 KB) file named

Appium Logs - Final.txt (315.8 KB)

Thank you@Aleksei for the solution of hubs for the devices.

I also tried Using builder.withCapabilities(Capabilities("deviceconfig")) within the AppiumDriverLocalService startServer()
it results in a “Connection refused” error.

The line number mentioned in error points to `builder.withCapabilities(Capabilities(“deviceconfig”)) in startserver() and
appiumDriver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), Capabilities); in Capabilities()
Using builder.capability.txt (12.9 KB)

Hello @Aleksei @wreed Could you help me with the latest implementation that I have tried and is it the feasible way ?

you use SAME appium port while number of appium servers should = number of devices you using.
some examples:
https://www.headspin.io/blog/running-multiple-appium-tests-in-parallel
https://www.swtestacademy.com/appium-paralllel-testing/

1 Like

I am using Python , Can you please help me to find the right test script to use on mutiple ios devices to perform parrallel execution

Are you running 16 devices in parallel on the system (I mean android virtual machine)!?

Because my system specifications are as follows:
MacBook Pro (Retina, 15-inch, Mid 2014)
2.5 GHz quad-core Intel Core i7
16 GB DDR3 1600 MHz

But when I run 3 devices, just 3 devices in parallel, the system becomes very heavy and the programs don’t work properly and usually crash after a few minutes!!

No. Real devices. To run 16 virtual better use several machines. Or some monsters like m2 Ultra. I bet cheap m2pro macMini faster then your similar (by price) x86 machine in times.