'Is it possible to execute cucumber scenario's in parallel on different browsers(chrome and firefox) at same time?

I succeeded to run cucumber scenario's in parallel but only on one browsertype(chrome or firefox). So first I run my tests on chrome. When tests finish I start a second test run on firefox.

Is it possible to run cucumber scenarios in parallel on different browsertypes at same time?

See cucumber bdd documentation how to achieve parallel execution of scenarios at https://cucumber.io/docs/guides/parallel-execution/

I use testNG as testrunner!

Thanks a lot for your responses!



Solution 1:[1]

You are running a your tests against a matrix of browsers. Typically this matrix configured in CI and provided to the test execution via environment variables. For example using Gitlab CI Matrix:

test:
  stage: test
  script:
    - mvn test
  parallel:
    matrix:
      - OS: Windows
        OS_VERSION: 10
        BROWSER: [Chrome, Firefox, Edge]
      - OS: OS X
        OS_VERSION: Big Sur
        BROWSER: [Chrome, Firefox, Edge, Safari]

You then create the web driver in the before hook using the environment variables.

    @Before
    public void before(Scenario scenario){
        String os = System.getenv("OS");
        String osVersion = System.getenv("OS_VERSION");
        String browser = System.getenv("BROWSER");
        driver = createDriver(os, osVersion, browser);
    }

You could also use Maven Profiles or Gradle Tasks to define these different sets of environment variables.

However key is to let these jobs in parallel on your CI system by starting multiple JVMs rather then only in Cucumber by starting multiple threads.

Solution 2:[2]

See the following answer Is it posible to run feature cucumber in parallel in different browser

This link at https://github.com/prashant-ramcharan/courgette-jvm-selenium explains how to achieve by using courgette-jvm(extension on cucumber-jvm).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 makhlo