Home > Back-end >  Is it possible to execute cucumber scenario's in parallel on different browsers(chrome and fire
Is it possible to execute cucumber scenario's in parallel on different browsers(chrome and fire

Time:05-13

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!

CodePudding user response:

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).

CodePudding user response:

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 in Cucumber by starting multiple threads.

  • Related