IOviSpot
IOviSpot

Reputation: 368

How to run a test on multiple devices in parallel?

I cannot manage to run one test script on more than one device no matter what.

I've got one test apk and test script pulled from some site as an example that finds a textbox in the app then inputs "Hello World!" into it then the script is done. I am trying to test the script on two devices as for now. I've created four batch scripts in which two run two instances of appium servers with different parameters and the other two that run two instances of the test script with different parameters also (which include capabilities).

Construction of the batch files:

run-servers.bat

start "Appium Server 1" appium -p 5000 -bp 5100 --session-override
start "Appium Server 2" appium -p 5001 -bp 5101 --session-override

(I do not know what --session-override is supposed to do exactly, since no description of it on the internet contains detailed, but with or without it, same results occur).

run-testscript.bat

start "Test 1" node testing.js 5000 9 Emulator-9 emulator-5554
start "Test 2" node testing.js 5001 7 Emulator-7 emulator-5556

(The extra parameters after the script file are:

<Port> <Android-Version> <Device Name> <Unique ID>)

And the script:

const driver = require("webdriverio");
const args = process.argv;

const caps = {

    port: parseInt(args[2]),
    capabilities: {

        platformName: "Android",
        platformVersion: args[3],
        deviceName: args[4],
        app: "D:/Node/Appium/Test/apk/ApiDemos-debug.apk",
        appPackage: "io.appium.android.apis",
        appActivity: ".view.TextFields",
        automationName: "UiAutomator2", 
        uniqueID: args[5]
    }
};

async function test(caps) {

    const client = await driver.remote(caps);

    const field = await client.$("android.widget.EditText");
    await field.setValue("Hello World!");
    const value = await field.getText();
    assert.equal(value, "Hello World!");

    await client.deleteSession();
}

test(caps);

When I run two instances of the test, the app starts on both devices, but on one device it doesn't input "Hello World!" while on the other does. There is also the "ECONNRESET: A server-side error occurred blah-blah" on the server which the device without input is on.

Upvotes: 0

Views: 932

Answers (1)

Danyal Zia
Danyal Zia

Reputation: 26

You need to add systemPort in your Appium configuration. Use different systemPort values for every device (e.g, 8201, 8202, etc.).

Please read Appium Desired Capabilities.

Upvotes: 1

Related Questions