Issues running tests on different browsers using behat and selenium

41 Views Asked by At

I've set up behat and selenium to run tests on chrome and it works fine, but now I want to try different browsers. But no matter what I do, Selenium always launches the chrome browser. I don't know what to do anymore.

This is my behat config file:

default:
  extensions:
    Drupal\DrupalExtension:
      blackbox: ~
      api_driver: 'drupal'
      drupal:
        drupal_root: './web'

chrome:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
      filters:
        tags: '~@firefox&&~@edge'
  extensions:
    Behat\MinkExtension:
      base_url: '[my_website]'
      selenium2:
        wd_host: "http://localhost:4444/wd/hub"
        capabilities:
          browserName: "chrome"

firefox:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
      filters:
        tags: '~@chrome&&~@edge'
  extensions:
    Behat\MinkExtension:
      base_url: '[my_website]'
      selenium2:
        wd_host: "http://localhost:4444/wd/hub"
        capabilities:
          browserName: "firefox"

edge:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
      filters:
        tags: '~@firefox&&~@chrome'
  extensions:
    Behat\MinkExtension:
      base_url: '[my_website]'
      selenium2:
        wd_host: "http://localhost:4444/wd/hub"
        capabilities:
          browserName: "MicrosoftEdge"

And this is the output in my console after launching selenium:

INFO [LogManager$RootLogger.log] - Using the system default encoding
INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
INFO [NodeOptions.getSessionFactories] - Detected 8 available processors
INFO [NodeOptions.discoverDrivers] - Discovered 3 driver(s)
INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome"} 8 times     
INFO [NodeOptions.report] - Adding Firefox for {"browserName": "firefox"} 8 times   
INFO [NodeOptions.report] - Adding Edge for {"browserName": "MicrosoftEdge"} 8 times
INFO [Node.<init>] - Binding additional locator mechanisms: name, id, relative
INFO [LocalDistributor.add] - Added node fcc0ebda-8ba2-48f0-ab29-7cee07f110f1 at http://10.5.110.196:4444. Health check every 120s
INFO [GridModel.setAvailability] - Switching node fcc0ebda-8ba2-48f0-ab29-7cee07f110f1 (uri: http://10.5.110.196:4444) from DOWN to UP
INFO [Standalone.execute] - Started Selenium Standalone 4.1.2 (revision 9a5a329c5a): http://10.5.110.196:4444

When I try to launch this command for example: vendor/bin/behat -p edge, I expect it to use my edge profile and launch the edge browser and the tests that are not chrome or firefox specific. It uses the right profile as the tests tagged with edge are launched but it launches chrome and this is the output in my selenium console:

INFO [LocalDistributor.newSession] - Session request received by the distributor: 
 [Capabilities {}, Capabilities {browser: firefox, browserName: firefox, ignoreZoomSetting: false, name: Behat feature suite, tags: [VMHF-DEV-23, PHP 8.1.17]}, Capabilities {browserName: firefox}]
Starting ChromeDriver 120.0.6099.71 (9729082fe6174c0a371fc66501f5efc5d69d3d2b-refs/branch-heads/6099_56@{#13}) on port 62956
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

Also, when I remove the Chrome and Firefox drivers from the directory they are all at, and relaunch selenium, it can run tests on Edge (or any other browser). So the drivers all work fine separately. (I'm also on windows 10, dont' know if it matters)

What do I do wrong that I can't run test on the browser I want?

0

There are 0 best solutions below