function WebDriverTestBase::initMink

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::initMink()
  2. 10 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

1 call to WebDriverTestBase::initMink()
SelectProfileFormTest::initMink in core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php
Initializes Mink sessions.
1 method overrides WebDriverTestBase::initMink()
SelectProfileFormTest::initMink in core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php
Initializes Mink sessions.

File

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

Class

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

Namespace

Drupal\FunctionalJavascriptTests

Code

protected function initMink() {
    if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) {
        $this->minkDefaultDriverArgs = [
            'chrome',
            NULL,
            'http://localhost:4444',
        ];
    }
    elseif ($this->minkDefaultDriverClass === PhantomJSDriver::class) {
        // Set up the template cache used by the PhantomJS mink driver.
        $path = $this->tempFilesDirectory . DIRECTORY_SEPARATOR . 'browsertestbase-templatecache';
        $this->minkDefaultDriverArgs = [
            'http://127.0.0.1:8510',
            $path,
        ];
        if (!file_exists($path)) {
            mkdir($path);
        }
    }
    try {
        return parent::initMink();
    } catch (DeadClient $e) {
        $this->markTestSkipped('PhantomJS is either not installed or not running. Start it via phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768&');
    } 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.