title: selenium grid/cucumber and docker compose: run a parallel test on several nodes
body: <p>In order to train myself in the technologies mentioned above, I created a project with a single test that checks a user’s navigation on the home page of the stackoverflow site.</p>
  <p>The hub and the 3 nodes of the selenium grid appear to be correctly configured
  The test runs correctly and I would now like to run this test simultaneously on several browsers.</p>
  <p>I wrote my test like this:
  cucumber:</p>
  <pre><code>Feature: search the home page of stackoverflow
  
    Scenario: Go to the site stackoverflow
      Given I'm on google search page
      When I enter the name of the site
      Then I'm navigated on the home page of stackoverflow
  </code></pre>
  <p>Selenium:</p>
  <pre><code>public class StepGoStackoverflowChrome {
      RemoteWebDriver driver;
      String nodeUrl;
  
      @Given(&quot;I'm on google search page&quot;)
      public void i_m_on_google_search_page() {
          try {
              nodeUrl = &quot;http://localhost:4444&quot;;
  
              ChromeOptions options = new ChromeOptions();
              // options.addArguments(&quot;--headless&quot;);
              options.addArguments(&quot;start-maximized&quot;);
  
              driver = new RemoteWebDriver(new URL(nodeUrl), options);
              driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
              driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
              driver.get(&quot;https://www.google.com&quot;);
          } catch (MalformedURLException error) {
              error.printStackTrace();
          }
      }
  
      @When(&quot;I enter the name of the site&quot;)
      public void i_enter_the_name_of_the_site() {
          WebElement webElementList = driver.findElement(By.id(&quot;L2AGLb&quot;));
          webElementList.click();
          driver.findElement(By.name(&quot;q&quot;)).sendKeys(&quot;stackoverflow&quot;, Keys.ENTER);
      }
  
      @Then(&quot;I'm navigated on the home page of stackoverflow&quot;)
      public void i_m_navigated_on_the_home_page_of_stackoverflow() {
          driver.findElement(By.xpath(&quot;//a[@href='https://stackoverflow.com/']&quot;)).click();
          driver.close();
      }
  }
  </code></pre>
  <p>and finally the docker file consists that launches 3 containers with images of web drivers chrome, firefox and edge:</p>
  <pre><code>version: &quot;3&quot;
  services:
    chrome:
      image: selenium/node-chrome:4.1.1-20211217
      shm_size: 2gb
      depends_on:
        - selenium-hub
      environment:
        - SE_EVENT_BUS_HOST=selenium-hub
        - SE_EVENT_BUS_PUBLISH_PORT=4442
        - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
        - SE_NODE_MAX_SESSIONS=2
  
    edge:
      image: selenium/node-edge:4.1.1-20211217
      shm_size: 2gb
      depends_on:
        - selenium-hub
      environment:
        - SE_EVENT_BUS_HOST=selenium-hub
        - SE_EVENT_BUS_PUBLISH_PORT=4442
        - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
        - SE_NODE_MAX_SESSIONS=3
  
    firefox:
      image: selenium/node-firefox:4.1.1-20211217
      shm_size: 2gb
      depends_on:
        - selenium-hub
      environment:
        - SE_EVENT_BUS_HOST=selenium-hub
        - SE_EVENT_BUS_PUBLISH_PORT=4442
        - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
        - SE_NODE_MAX_SESSIONS=3
  
    selenium-hub:
      image: selenium/hub:4.1.1-20211217
      container_name: selenium-hub
      ports:
        - &quot;4442:4442&quot;
        - &quot;4443:4443&quot;
        - &quot;4444:4444&quot;
  </code></pre>
  <p>I finally run the docker composes with the command:</p>
  <pre><code>docker-compose -f docker-compose.yml up
  </code></pre>
  <p>I duplicated the test class by modifying the use of <code>ChromeOptions</code> by <code>FireFoxOption</code> and <code>InterneExplorerOptions</code> in the hope that the tests would start, but I had doubts. This gives the following error:</p>
  <pre><code>Exception in thread &quot;main&quot; io.cucumber.core.exception.CucumberException: 
  
      io.cucumber.core.runner.DuplicateStepDefinitionException: Duplicate step definitions in com.seleniumtest.formation.demo.cucumber.steps.StepGoStackoverflowChrome.i_m_on_google_search_page() and com.seleniumtest.formation.demo.cucumber.steps.StepGoStackoverflowFirefox.i_m_on_google_search_page()
  </code></pre>
  <p>I understand that this creates a language ambiguity in the definition of the test steps with cucumber. Do you have tutorials or ideas for me to consider.
  Thank you</p>