function WebDriverTestBase::initMink

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::initMink()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::initMink()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::initMink()

Overrides BrowserTestBase::initMink

File

core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php, line 47

Class

WebDriverTestBase
Runs a browser test using a driver that supports JavaScript.

Namespace

Drupal\FunctionalJavascriptTests

Code

protected function initMink() {
    if (!is_a($this->minkDefaultDriverClass, DrupalSelenium2Driver::class, TRUE)) {
        throw new \UnexpectedValueException(sprintf("%s has to be an instance of %s", $this->minkDefaultDriverClass, DrupalSelenium2Driver::class));
    }
    $this->minkDefaultDriverArgs = [
        'chrome',
        [
            'goog:chromeOptions' => [
                'w3c' => FALSE,
            ],
        ],
        'http://localhost:4444',
    ];
    try {
        return parent::initMink();
    } catch (DriverException $e) {
        if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) {
            $this->markTestSkipped("The test wasn't able to connect to your webdriver instance. For more information read core/tests/README.md.\n\nThe original message while starting Mink: {$e->getMessage()}");
        }
        else {
            throw $e;
        }
    } catch (\Exception $e) {
        $this->markTestSkipped('An unexpected error occurred while starting Mink: ' . $e->getMessage());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.