You are here

protected function WebDriverTestBase::initMink in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::initMink()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::initMink()

Initializes Mink sessions.

Overrides BrowserTestBase::initMink

File

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

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',
    NULL,
    '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());
  }
}