Start tests in a specific Appium node (Selenium Grid)?

What I want to do:

I want to start a test on a specific Appium node (Selenium Grid).

My problem:

My tests run, but they always run in the same Appium node. I’m not talking about running them in parallel. I just want to specify the Appium node.

Questions:

Is that actually possible ? It just takes the node that was first registered, what could be the reason it is always started in the same node ?

Here is my config and what I do, first I start the Appium node like that:

appium -a 127.0.0.1 -p 6002 -bp 5723 --udid mydevice1 --nodeconfig /mydevice1.json

Second:

appium -a 127.0.0.1 -p 6003 -bp 5724 --udid mydevice2 --nodeconfig /mydevice2.json

The nodeconfig for mydevice1 looks like that:

{
“capabilities”:
[
{
“deviceName”:“mydevice1”,
“version”:“6.0.1”,
“maxInstances”: 2,
“platformName”:“ANDROID”
}
],
“configuration”:
{
“cleanUpCycle”:2000,
“timeout”:30000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”:“http://127.0.0.1:6002/wd/hub”,
“host”: “127.0.0.1”,
“port”: 6002,
“maxSession”: 2,
“register”: true,
“registerCycle”: 5000,
“hubPort”: 4444,
“hubHost”: “127.0.0.1”,
“session-override”: true

}
}

The nodeconfig for mydevice2 looks like that:

{
“capabilities”:
[
{
“deviceName”:“mydevice2”,
“version”:“5.0.1”,
“maxInstances”: 2,
“platformName”:“ANDROID”
}
],
“configuration”:
{
“cleanUpCycle”:2000,
“timeout”:30000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”:“http://127.0.0.1:6003/wd/hub”,
“host”: “127.0.0.1”,
“port”: 6003,
“maxSession”: 2,
“register”: true,
“registerCycle”: 5000,
“hubPort”: 4444,
“hubHost”: “127.0.0.1”,
“session-override”: true

}
}

The test script:

capabilities.setCapability(MobileCapabilityType.APP, “/folder/test.apk”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “ANDROID”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “My Device 1”);
capabilities.setCapability(MobileCapabilityType.DEVICE_READY_TIMEOUT, “7200”);
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT , “7200”);
capabilities.setCapability(MobileCapabilityType.UDID, “mydevice1”);

Thank you so much ! Best, Michael :wink:

Is there a particular reason you want one node over the other? The only reason I see immediately is that you want one particular Android version over the other.

Anyway, first suggestion:

  1. Drop the UDID capability from your test code. Whichever Appium node the grid selects for you will overwrite the default UDID you handed in when you started the node with the one you specify in your test code.
  2. What happens if you include the platform version in the capability? I believe Selenium will then try to match up your desired capabilities with the node that matches the capability.

Hi,

The thing you just need to do,
give your device1 udid1 capability to the respective appium port number : http://0.0.0.0:6002/wd/hub and
device2 udid2 capability to the respective appium port number : http://0.0.0.0:6003/wd/hub. You may customize your tests by usingTestNG framework.

Hope this helps.

Thanks & Regards,
Bhaskar.