/**
  * @return NodeElement
  *
  * @throws ElementNotFoundException
  */
 private function getMessageElement()
 {
     $messageElement = $this->session->getPage()->find('css', self::NOTIFICATION_ELEMENT_CSS);
     if (null === $messageElement) {
         throw new ElementNotFoundException($this->session->getDriver(), 'message element', 'css', self::NOTIFICATION_ELEMENT_CSS);
     }
     return $messageElement;
 }
Example #2
0
 private function prepareMinkSessionIfNeeded()
 {
     if ($this->minkSession->getDriver() instanceof KernelDriver) {
         return;
     }
     if (false !== strpos($this->minkSession->getCurrentUrl(), $this->minkParameters['base_url'])) {
         return;
     }
     $this->minkSession->visit(rtrim($this->minkParameters['base_url'], '/') . '/');
 }
Example #3
0
 private function prepareSessionIfNeeded()
 {
     if (!$this->minkSession->getDriver() instanceof Selenium2Driver) {
         return;
     }
     if (false !== strpos($this->minkSession->getCurrentUrl(), $this->minkParameters['base_url'])) {
         return;
     }
     $this->homePage->open();
 }
Example #4
0
 /**
  * Initialize element.
  *
  * @param Session $session
  */
 public function __construct(Session $session)
 {
     $this->xpathManipulator = new Manipulator();
     $this->session = $session;
     $this->driver = $session->getDriver();
     $this->selectorsHandler = $session->getSelectorsHandler();
 }
Example #5
0
 function it_loads_base_url_and_sets_a_cookie_if_not_using_kernel_driver_and_driver_is_currently_outside_base_url(Session $minkSession, DriverInterface $driver)
 {
     $minkSession->getDriver()->willReturn($driver);
     $minkSession->getCurrentUrl()->willReturn('http://sylius.org');
     $minkSession->visit('http://localhost:8080/')->shouldBeCalled();
     $minkSession->setCookie('abc', 'def')->shouldBeCalled();
     $this->setCookie('abc', 'def');
 }
Example #6
0
 /**
  * Get the Symfony driver.
  * 
  * @return BrowserKitDriver
  *
  * @throws UnsupportedDriverActionException when not using mink browser kit driver
  */
 protected function getSymfonyDriver()
 {
     $driver = $this->session->getDriver();
     if ($driver instanceof BrowserKitDriver === false) {
         throw new UnsupportedDriverActionException('Not using the Symfony Driver - current driver is %s', $driver);
     }
     return $driver;
 }
Example #7
0
 /**
  * Returns response information string.
  *
  * @return  string
  */
 protected function getResponseInfo()
 {
     $driver = basename(str_replace('\\', '/', get_class($this->session->getDriver())));
     $info = '+--[ ';
     if (!in_array($driver, array('SahiDriver', 'SeleniumDriver'))) {
         $info .= 'HTTP/1.1 ' . $this->session->getStatusCode() . ' | ';
     }
     $info .= $this->session->getCurrentUrl() . ' | ' . $driver . " ]\n|\n";
     return $info;
 }
Example #8
0
 /**
  * Initializes exception.
  *
  * @param string                  $message   optional message
  * @param DriverInterface|Session $driver    driver instance (or session for BC)
  * @param \Exception|null         $exception expectation exception
  */
 public function __construct($message, $driver, \Exception $exception = null)
 {
     if ($driver instanceof Session) {
         @trigger_error('Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.', E_USER_DEPRECATED);
         $this->session = $driver;
         $this->driver = $driver->getDriver();
     } elseif (!$driver instanceof DriverInterface) {
         // Trigger an exception as we cannot typehint a disjunction
         throw new \InvalidArgumentException('The ExpectationException constructor expects a DriverInterface or a Session.');
     } else {
         $this->driver = $driver;
     }
     if (!$message && null !== $exception) {
         $message = $exception->getMessage();
     }
     parent::__construct($message, 0, $exception);
 }
Example #9
0
 /**
  * @return DriverInterface
  */
 protected function getDriver()
 {
     return $this->session->getDriver();
 }
 public function testGetDriver()
 {
     $this->assertSame($this->driver, $this->session->getDriver());
 }
Example #11
0
 public function _sendRequest($url)
 {
     $this->session->visit($url);
     return $this->session->getDriver()->getContent();
 }
 /**
  * Get Selenium2 current session id.
  *
  * @param Session $session Session.
  *
  * @return string
  * @throws \RuntimeException When session was created using an unsupported driver.
  */
 protected function getSessionId(Session $session)
 {
     $driver = $session->getDriver();
     if ($driver instanceof Selenium2Driver) {
         return $driver->getWebDriverSessionId();
     }
     throw new \RuntimeException('Unsupported session driver');
 }
Example #13
0
 /**
  * @param Session $session
  *
  * @return string|null
  */
 private function getRequestDataLogMessage(Session $session)
 {
     $driver = $session->getDriver();
     if (!$driver instanceof BrowserKitDriver) {
         return null;
     }
     try {
         return 'Request:' . "\n" . print_r($driver->getClient()->getRequest(), true) . "\n";
     } catch (MinkException $exception) {
         return null;
     }
 }
Example #14
0
 /**
  * @return Client
  */
 private function getClient()
 {
     return $this->session->getDriver()->getClient();
 }