Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / FunctionalJavascriptTests / DrupalSelenium2Driver.php
1 <?php
2
3 namespace Drupal\FunctionalJavascriptTests;
4
5 use Behat\Mink\Driver\Selenium2Driver;
6 use WebDriver\ServiceFactory;
7
8 /**
9  * Provides a driver for Selenium testing.
10  */
11 class DrupalSelenium2Driver extends Selenium2Driver {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function __construct($browserName = 'firefox', $desiredCapabilities = NULL, $wdHost = 'http://localhost:4444/wd/hub') {
17     parent::__construct($browserName, $desiredCapabilities, $wdHost);
18     ServiceFactory::getInstance()->setServiceClass('service.curl', WebDriverCurlService::class);
19   }
20
21   /**
22    * {@inheritdoc}
23    */
24   public function setCookie($name, $value = NULL) {
25     if ($value === NULL) {
26       $this->getWebDriverSession()->deleteCookie($name);
27       return;
28     }
29
30     $cookieArray = [
31       'name' => $name,
32       'value' => urlencode($value),
33       'secure' => FALSE,
34       // Unlike \Behat\Mink\Driver\Selenium2Driver::setCookie we set a domain
35       // and an expire date, as otherwise cookies leak from one test site into
36       // another.
37       'domain' => parse_url($this->getWebDriverSession()->url(), PHP_URL_HOST),
38       'expires' => time() + 80000,
39     ];
40
41     $this->getWebDriverSession()->setCookie($cookieArray);
42   }
43
44 }