annotate core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author |
Chris Cannam |
date |
Thu, 28 Feb 2019 13:11:55 +0000 |
parents |
c75dbcec494b |
children |
12f9dff5fda9 |
rev |
line source |
Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\FunctionalJavascriptTests;
|
Chris@0
|
4
|
Chris@0
|
5 use Behat\Mink\Driver\Selenium2Driver;
|
Chris@4
|
6 use WebDriver\ServiceFactory;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Provides a driver for Selenium testing.
|
Chris@0
|
10 */
|
Chris@0
|
11 class DrupalSelenium2Driver extends Selenium2Driver {
|
Chris@0
|
12
|
Chris@0
|
13 /**
|
Chris@0
|
14 * {@inheritdoc}
|
Chris@0
|
15 */
|
Chris@4
|
16 public function __construct($browserName = 'firefox', $desiredCapabilities = NULL, $wdHost = 'http://localhost:4444/wd/hub') {
|
Chris@4
|
17 parent::__construct($browserName, $desiredCapabilities, $wdHost);
|
Chris@4
|
18 ServiceFactory::getInstance()->setServiceClass('service.curl', WebDriverCurlService::class);
|
Chris@4
|
19 }
|
Chris@4
|
20
|
Chris@4
|
21 /**
|
Chris@4
|
22 * {@inheritdoc}
|
Chris@4
|
23 */
|
Chris@0
|
24 public function setCookie($name, $value = NULL) {
|
Chris@0
|
25 if ($value === NULL) {
|
Chris@0
|
26 $this->getWebDriverSession()->deleteCookie($name);
|
Chris@0
|
27 return;
|
Chris@0
|
28 }
|
Chris@0
|
29
|
Chris@0
|
30 $cookieArray = [
|
Chris@0
|
31 'name' => $name,
|
Chris@0
|
32 'value' => urlencode($value),
|
Chris@0
|
33 'secure' => FALSE,
|
Chris@0
|
34 // Unlike \Behat\Mink\Driver\Selenium2Driver::setCookie we set a domain
|
Chris@0
|
35 // and an expire date, as otherwise cookies leak from one test site into
|
Chris@0
|
36 // another.
|
Chris@0
|
37 'domain' => parse_url($this->getWebDriverSession()->url(), PHP_URL_HOST),
|
Chris@0
|
38 'expires' => time() + 80000,
|
Chris@0
|
39 ];
|
Chris@0
|
40
|
Chris@0
|
41 $this->getWebDriverSession()->setCookie($cookieArray);
|
Chris@0
|
42 }
|
Chris@0
|
43
|
Chris@0
|
44 }
|