How to run 2 Parallel devices with appium

I use wdio http://v4.webdriver.io/

  1. I have to connect 2 android devices
  2. Run two different script in 2 devices

I have capabilities like:
[
{ mjpegServerPort: 9202,
systemPort: 8202,
maxInstances: 1,
appiumVersion: ‘1.16.0’,
platformName: ‘Android’,
platformVersion: ‘5.1.1’,
deviceName: ‘…’,
…},
{ mjpegServerPort: 9203,
systemPort: 8203,
maxInstances: 1,
appiumVersion: ‘1.16.0’,
platformVersion: ‘6.0.1’,
deviceName: ‘…’, }
… ]
config.maxInstances = 2;

When I started script I had two parallel .
[00:56:00] COMMAND POST “/wd/hub/session”
[00:56:00] DATA {“desiredCapabilities”:{“javascriptEnabled”:true,“locationContextEnabled”:true,“handlesAlerts”:true,“rotatable”:true,“mjpegServerPort”:9202,“systemPort”:8202,“maxInstances”:1,“appiumVersion”:“1.16.0”,“platformName”:“Android”,“appPackage”:"r…
[00:56:00] COMMAND POST “/wd/hub/session”
[00:56:00] DATA {“desiredCapabilities”:{“javascriptEnabled”:true,“locationContextEnabled”:true,“handlesAlerts”:true,“rotatable”:true,“mjpegServerPort”:9203,“systemPort”:8203,“maxInstances”:1,“appiumVersion”:“1.16.0”,“platformName”:“Android”,“appPackage”:…

But a first script run to both devices, and then a second script too.

I want: a first test run to a first device, a second test run to a second device

Please help find a solution

it is mandatory to set udid capability for each device.

I add it, but it not fix my problem (

There’s nothing more to say without the detailed server logs

here do not need logs (
Fundamentally, the apium is configured are two devices (not semmetric), then it runs one test in parallel on two devices.

I need to distribution tests between devices.

I am looking for similar approach. I’ll provide more than 1 capability and I want the specs to be automatically distributed into attached device but should not run all given specs in each device.

For example, consider below config file where I have 4 specs with 2 attached devices provided under caps. If I run this, 4 specs are getting executed on each device (4x2 specs), duplicating the execution. But, this doesn’t give any error or exception. Instead, my requirement is, the specs should be divided/distributed to each device which make final executed specs count to be 4.

config.specs = [
    './tests/specs/**/app*.spec.js',
    './tests/specs/**/app.forms.spec.js',
    './tests/specs/**/app.login.spec.js',
    './tests/specs/**/app.logout.spec.js',
];
config.capabilities = [
    {
        platformName: 'Android',
        maxInstances: 1,
        'appium:deviceName': 'xxxxxxxx',
        'appium:platformVersion': '10.3.7',
        'appium:orientation': 'PORTRAIT',
        'appium:automationName': 'UiAutomator2',
        'appium:app': join(process.cwd(), './app/Android-NativeDemoApp-0.2.1.apk'),
        udid: 'xxxxxxx',
        'appium:noReset': true,
        'appium:newCommandTimeout': 240,
        systemPort: 8210,
    },
    {
        platformName: 'Android',
        maxInstances: 1,
        'appium:deviceName': 'xxxxxxx',
        'appium:platformVersion': '11.0',
        'appium:orientation': 'PORTRAIT',
        'appium:automationName': 'UiAutomator2',
        'appium:app': join(process.cwd(), './app/Android-NativeDemoApp-0.2.1.apk'),
        udid: 'xxxxxxxx',
        'appium:noReset': true,
        'appium:newCommandTimeout': 240,
        systemPort: 8211,
    },
];

Please provide workaround for this. Thanks in advance!

Any update on above query?

Hi @GouthamDuduka did you find a solution on how to do this

Hello ,
If you have solution for the above configuration to run parallel , please let me know

Any solution on the above

Here is the Appium documentation on parallel executions:

https://appium.io/docs/en/advanced-concepts/parallel-tests/

And here is a nice blog (with source code) that walks through such testing:

https://medium.com/quinbay/appium-with-parallel-execution-part-1-db44cc1c2458

Good luck!