DrupalSelenium2Driver.php 855 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Drupal\FunctionalJavascriptTests;
  3. use Behat\Mink\Driver\Selenium2Driver;
  4. /**
  5. * Provides a driver for Selenium testing.
  6. */
  7. class DrupalSelenium2Driver extends Selenium2Driver {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function setCookie($name, $value = NULL) {
  12. if ($value === NULL) {
  13. $this->getWebDriverSession()->deleteCookie($name);
  14. return;
  15. }
  16. $cookieArray = [
  17. 'name' => $name,
  18. 'value' => urlencode($value),
  19. 'secure' => FALSE,
  20. // Unlike \Behat\Mink\Driver\Selenium2Driver::setCookie we set a domain
  21. // and an expire date, as otherwise cookies leak from one test site into
  22. // another.
  23. 'domain' => parse_url($this->getWebDriverSession()->url(), PHP_URL_HOST),
  24. 'expires' => time() + 80000,
  25. ];
  26. $this->getWebDriverSession()->setCookie($cookieArray);
  27. }
  28. }