Mink failing to run JavascriptTestBase tests I suspect this is more a config issue than anything but struggling to run JavascriptTestBase tests. The error I'm getting is as below:


  wodby@php.container:/var/www/html $ ./bin/phpunit -v -c ./web/core
  ./web/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebWithWebDriverAssertTest.php
  PHPUnit 6.5.8 by Sebastian Bergmann and contributors.
  
  Runtime:       PHP 7.1.17 Configuration:
  /var/www/html/web/core/phpunit.xml
  
  Testing
  Drupal\FunctionalJavascriptTests\Tests\JSWebWithWebDriverAssertTest S 
  1 / 1 (100%)
  
  Time: 21.2 seconds, Memory: 6.00MB
  
  There was 1 skipped test:
  
  1)
  Drupal\FunctionalJavascriptTests\Tests\JSWebWithWebDriverAssertTest::testJsWebAssert
  An unexpected error occurred while starting Mink: Could not open
  connection: Error forwarding the new session cannot find :
  Capabilities {browser: firefox, browserName: chrome, browserVersion:
  9, deviceOrientation: portrait, deviceType: tablet, name: Behat Test,
  selenium-version: 2.31.0, version: 9}
  
  /var/www/html/web/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php:50
  /var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php:484
  
  OK, but incomplete, skipped, or risky tests! Tests: 1, Assertions: 1,
  Skipped: 1.


I'm running this directly within a docker container. Selenium is also running in a docker container and I know I can connect from my PHP/Apache container to the Selenium container as running

wget http://selenium:4444/grid/console


Returns the selenium Grid Console homepage.

My phpunit.xml file looks as follows:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;phpunit bootstrap="tests/bootstrap.php" colors="true"
         beStrictAboutTestsThatDoNotTestAnything="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutChangesToGlobalState="true"&gt;
  &lt;php&gt;
    &lt;ini name="error_reporting" value="32767"/&gt;
    &lt;ini name="memory_limit" value="-1"/&gt;
    &lt;env name="SIMPLETEST_BASE_URL" value="http://apache"/&gt;
    &lt;env name="SIMPLETEST_DB" value="mysql://drupal:drupal@mariadb/drupal"/&gt;
    &lt;env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/&gt;
    &lt;env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors"/&gt;
    &lt;env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", null, "http://selenium:4444/wd/hub"]'/&gt;
  &lt;/php&gt;
  &lt;testsuites&gt;
    &lt;testsuite name="unit"&gt;
      &lt;file&gt;./tests/TestSuites/UnitTestSuite.php&lt;/file&gt;
    &lt;/testsuite&gt;
    &lt;testsuite name="kernel"&gt;
      &lt;file&gt;./tests/TestSuites/KernelTestSuite.php&lt;/file&gt;
    &lt;/testsuite&gt;
    &lt;testsuite name="functional"&gt;
      &lt;file&gt;./tests/TestSuites/FunctionalTestSuite.php&lt;/file&gt;
    &lt;/testsuite&gt;
    &lt;testsuite name="functional-javascript"&gt;
      &lt;file&gt;./tests/TestSuites/FunctionalJavascriptTestSuite.php&lt;/file&gt;
    &lt;/testsuite&gt;
  &lt;/testsuites&gt;
  &lt;listeners&gt;
    &lt;listener class="\Drupal\Tests\Listeners\DrupalListener"&gt;
    &lt;/listener&gt;
    &lt;listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"&gt;
    &lt;/listener&gt;
  &lt;/listeners&gt;
  &lt;filter&gt;
    &lt;whitelist&gt;
      &lt;directory&gt;./includes&lt;/directory&gt;
      &lt;directory&gt;./lib&lt;/directory&gt;
      &lt;directory&gt;./modules&lt;/directory&gt;
      &lt;directory&gt;../modules&lt;/directory&gt;
      &lt;directory&gt;../sites&lt;/directory&gt;
      &lt;exclude&gt;
        &lt;directory suffix="Test.php"&gt;./&lt;/directory&gt;
        &lt;directory suffix="TestBase.php"&gt;./&lt;/directory&gt;
      &lt;/exclude&gt;
     &lt;/whitelist&gt;
  &lt;/filter&gt;
&lt;/phpunit&gt;


Could anyone give me any pointers in the right direction?
There's an annoying bug with the Selenium2Driver code with regards to specifying the correct browser. If no capabilities are specified, it uses the defaults:

    public function setDesiredCapabilities($desiredCapabilities = null)
    {
        if (null === $desiredCapabilities) {
            $desiredCapabilities = self::getDefaultCapabilities();
        }


Note in the error it hase browser defaulted to firefox while the browserName is correctly set to chrome:

Capabilities {browser: firefox, browserName: chrome,


In order to workaround this issue, change your capabilities to also specify browser:

&lt;env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browser": "chrome"}, "http://selenium:4444/wd/hub"]'/&gt;