2

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:

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

Could anyone give me any pointers in the right direction?

1

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:

<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browser": "chrome"}, "http://selenium:4444/wd/hub"]'/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy