Selenium grid 4.4 with Appium & Cucumber

I’m trying to set up a project to use Selenium grid 4.4. with Appium, using Cucumber and TestNG.

What I have by now is a runner class:

    features = {"src/test/resources/test_cases/"},
    glue = {"cucumber.steps", "cucumber.step_definition"},
    plugin = {"pretty", "html:target/cucumber-report.html", "json:target/cucumber-report/report.json"})

  public class CucumberLocalTestRunnerTest extends AbstractTestNGCucumberTests {

  @DataProvider(parallel = true)
  public Object[][] scenarios() {
    return super.scenarios();

And in the src/test/resources/test_cases/ there are two test cases.
I started selenium grid in standalone mode with Config.toml to set up the relay that communicates with Appium:

port = 5555

detect-drivers = false
max-session = 2

# Default Appium server endpoint
url = "http://localhost:4723/wd/hub"
status-endpoint = "/status"
# Stereotypes supported by the service
configs = [
    "1", "{\"browserName\": \"iPhone 12 Pro\",\"platformName\": \"ios\", \"appium:platformVersion\": \"15.0\", \"appium:udid\": \"7772811E-E56D-4AA5-98A0-2F6E453F6206\"}",
    "1", "{\"browserName\": \"iPhone 12 Pro\",\"platformName\": \"ios\", \"appium:platformVersion\": \"15.0\", \"appium:udid\": \"C2C77106-DA40-4BAE-B9C0-EB5EE62F5654\"}"


And Gradle task as:

task testNGTestTask(type: Test){
    scanForTestClasses = false
    testLogging.showStandardStreams = true
    systemProperties System.getProperties()
    systemProperty "cucumber.options", System.getProperty("cucumber.options")
    systemProperty "isIOS", System.getProperty("isIOS", "true")

    filter {
        includeTestsMatching 'cucumber.runners.CucumberLocalTestRunnerTest'

When I start the task with 2 threads, both test cases are run in parallel. Both of them have the same desired capabilities to use iPhone 12 Pro with OS 15.0.

What I don’t understand is why are both of them run on the same device and not using separate simulator devices?
I made sure to have created 2 iPhone 12 Pro simulators with the same OS version.

What am I missing here?

Do the Simulators have the exact same name? Can you try naming them slightly differently? I don’t think appium uses the udid with simulators. Maybe ‘1 iPhone Pro’ and ‘2 iPhone Pro’.

What I want to achieve is that when I run 2 tests with the same device name and OS version, system to detect automatically which device is available and assign available device to each test.

Honestly, I thought this is what selenium grid 4 is for… :confused:

Probably will work, but if 2 devices are exactly the same, system will probably always take the first one it finds. I’m guessing this means you won’t even try my solution?

I did try that and it still did not work. App was installed on both devices, but commands were send to the same device. I figured it out and the problem was the WebDriverAgent port as both devices were listening to the same port (8100). I changed that and now it works. :white_check_mark:

Thanks for your help.

1 Like