public function rebootSessionDriver()
 {
     $driver = $this->mink->getSession('silex')->getDriver();
     if ($driver instanceof KernelDriver) {
         $driver->reboot($this->manager->getBootedApplication());
     }
 }
Esempio n. 2
0
 /**
  * Save the screenshot as the given filename
  *
  * @param string $fileName
  */
 public function takeScreenshot($fileName = 'failure.png')
 {
     $screenshot = $this->mink->getSession()->getScreenshot();
     foreach ($this->imageDrivers as $imageDriver) {
         $imageUrl = $imageDriver->upload($screenshot, $fileName);
         $this->output->writeln('Screenshot has been taken. Open image at ' . $imageUrl);
     }
 }
 /**
  * Save the screenshot into a local buffer
  */
 public function takeScreenshot()
 {
     try {
         $this->screenshots[] = $this->mink->getSession()->getScreenshot();
     } catch (UnsupportedDriverActionException $e) {
         return;
     } catch (\Exception $e) {
         $this->output->writeln($e->getMessage());
     }
 }
 public function dragByPixels($selector, $pixelsX, $pixelsY)
 {
     $session = $this->mink->getSession()->getDriver()->getWebDriverSession();
     $el = $session->element('css selector', $selector);
     $session->moveto(['element' => $el->getID(), 'xoffset' => 2, 'yoffset' => 2]);
     $session->buttondown("");
     $session->moveto(['element' => null, 'xoffset' => (int) $pixelsX, 'yoffset' => (int) $pixelsY]);
     $session->buttonup("");
     usleep(50000);
 }
Esempio n. 5
0
 /**
  * @Given /^I wait until I am on "([^"]*)"$/
  */
 public function iWaitUntilIAmOn($location)
 {
     $tries = 15;
     $fullLocation = $this->minkParameters['base_url'] . $location;
     for ($c = 0; $c < $tries; $c++) {
         if ($fullLocation != $this->mink->getSession()->getCurrentUrl()) {
             sleep(1);
             continue;
         } else {
             return;
         }
     }
     throw new \Exception("Timed out waiting for URL to be: {$fullLocation}");
 }
 /**
  * Adds Basic HTTP Auth to the Mink session before each scenario.
  *
  * @throws \InvalidArgumentException
  */
 public function setBasicAuth()
 {
     $auth = $this->auth;
     if (null !== $auth['user']) {
         $this->mink->getSession()->setBasicAuth($auth['user'], $auth['password']);
     }
 }
 function it_should_call_the_image_upload_with_correct_params(Mink $mink, Session $session, Local $localImageDriver)
 {
     $mink->getSession()->willReturn($session);
     $session->getScreenshot()->willReturn('binary-image');
     $localImageDriver->upload('binary-image', 'test.png')->shouldBeCalled();
     $this->takeScreenshot('test.png');
 }
Esempio n. 8
0
 /**
  * @param string $pageClass
  *
  * @return SymfonyPage
  */
 private function instantiatePage($pageClass)
 {
     if (!is_subclass_of($pageClass, SymfonyPage::class)) {
         throw new \InvalidArgumentException(sprintf('Invalid page object class: %s, to use this factory you need to extend SymfonyPage', $pageClass));
     }
     return new $pageClass($this->mink->getSession(), $this, $this->pageParameters, $this->router);
 }
 /**
  * @param AfterStepTested $event
  * @throws JavaScriptException\UnknownErrorException
  * @throws JavaScriptErrorExceptionInterface
  */
 public function showJavaScriptErrors(AfterStepTested $event)
 {
     $session = $this->mink->getSession();
     $errors = $session->evaluateScript('ErrorHandler.get();');
     $exception = null;
     foreach ($errors as $error) {
         switch ($error['type']) {
             case 'error':
                 $exception = new JavaScriptException\JavaScriptErrorException($this->formatMessage($error), 0, $exception);
                 break;
             case 'ajaxError':
                 $exception = new JavaScriptException\AjaxErrorException($this->formatMessage($error), 0, $exception);
                 break;
             default:
                 throw new JavaScriptException\UnknownErrorTypeException(sprintf('Unknown error type received "%s"', $error['type']));
                 break;
         }
     }
     $session->executeScript('ErrorHandler.clear()');
     if (null !== $exception) {
         throw $exception;
     }
 }
Esempio n. 10
0
 public function testIsSessionStarted()
 {
     $session_1 = $this->getSessionMock();
     $session_2 = $this->getSessionMock();
     $session_1->expects($this->any())->method('isStarted')->will($this->returnValue(false));
     $session_1->expects($this->never())->method('start');
     $session_2->expects($this->any())->method('isStarted')->will($this->returnValue(true));
     $session_2->expects($this->never())->method('start');
     $this->mink->registerSession('not_started', $session_1);
     $this->assertFalse($this->mink->isSessionStarted('not_started'));
     $this->mink->registerSession('started', $session_2);
     $this->assertTrue($this->mink->isSessionStarted('started'));
     $this->setExpectedException('InvalidArgumentException');
     $this->mink->getSession('not_registered');
 }
Esempio n. 11
0
 /**
  * @Then /^I click (?:on )?"([^"]+)" in mail$/
  */
 public function clickInMail($text)
 {
     $message = $this->getCurrentMessage();
     if ($message->hasPart('text/html')) {
         $links = $this->getCrawler($message)->filter('a')->each(function ($link) {
             return array('href' => $link->attr('href'), 'text' => $link->text());
         });
     } else {
         throw new \RuntimeException(sprintf('Unable to click in mail'));
     }
     $href = null;
     foreach ($links as $link) {
         if (false !== strpos($link['text'], $text)) {
             $href = $link['href'];
             break;
         }
     }
     if (null === $href) {
         throw new \RuntimeException(sprintf('Unable to find link "%s" in those links: "%s".', $text, implode('", "', array_map(function ($link) {
             return $link['text'];
         }, $links))));
     }
     return $this->mink->getSession($this->mink->getDefaultSessionName())->visit($href);
 }
 private function initializeMinkStub(Mink $mink, Session $session)
 {
     $mink->getSession()->willReturn($session);
 }
Esempio n. 13
0
 /**
  * @param null $name
  *
  * @return Session
  */
 private function getSession($name = null)
 {
     return $this->mink->getSession($name);
 }
 public function __construct(array $parameters)
 {
     $mink = new Mink(array('selenium2' => new Session(new Selenium2Driver($parameters['wd_capabilities']['browser'], $parameters['wd_capabilities'], $parameters['wd_host']))));
     $this->gui = $mink->getSession('selenium2');
 }
 /**
  * Gets the current Mink session.
  *
  * @return \Behat\Mink\Session
  */
 protected function getSession()
 {
     return $this->mink->getSession();
 }
Esempio n. 16
0
 /**
  * Returns Mink session.
  *
  * @param string $name
  *   (optional) Name of the session. Defaults to the active session.
  *
  * @return \Behat\Mink\Session
  *   The active Mink session object.
  */
 public function getSession($name = NULL)
 {
     return $this->mink->getSession($name);
 }
 /**
  * Prepare session and page factory for the tests.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->session = self::$mink->getSession();
     $this->pageFactory = $this->createFactory();
 }
Esempio n. 18
0
 /**
  * @param null|string $name
  *
  * @return Session
  */
 protected function getSession($name = null)
 {
     return $this->mink->getSession($name);
 }
Esempio n. 19
0
                $min_visible_y = $min_visible_y > $y ? $y : $min_visible_y;
                $max_visible_y = $max_visible_y < $y ? $y : $max_visible_y;
            }
        }
    }
    $image = imagecrop($image, ['x' => $min_visible_x, 'y' => $min_visible_y, 'width' => $max_visible_x, 'height' => $max_visible_y]);
    imagefilter($image, IMG_FILTER_GRAYSCALE);
    $tmpfname = tempnam("/tmp", "OCR");
    imagepng($image, $tmpfname);
    $txt = $ocr->recognize($tmpfname, ['eng'], 3);
    unlink($tmpfname);
    return str_replace("\n", "", $txt);
}
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(CURLOPT_VERBOSE => 1, CURLOPT_CERTINFO => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_SSLVERSION => 3, CURLOPT_TIMEOUT => 30, CURLOPT_HTTPHEADER => ['Connection: keep-alive', 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Encoding: gzip, deflate', 'Cache-Control: max-age=0'], CURLOPT_URL => 'https://agenciavirtual.light.com.br/LASView/captcha.jpg', CURLOPT_USERAGENT => 'Codular Sample cURL Request'));
// Send the request & save response to $resp
$resp = curl_exec($curl);
var_dump(curl_error($curl));
var_dump(curl_getinfo($curl, CURLINFO_HTTP_CODE));
// var_dump(curl_getinfo($curl));
var_dump($resp);
// Close request to clear up some resources
curl_close($curl);
return;
$mink = new Mink(['goutte' => new Session(new GoutteDriver())]);
$session = $mink->getSession('goutte');
$session->visit('https://agenciavirtual.light.com.br/LASView/av/emissaosegundavia/emissaoSegundaVia.do');
$return = $session->getPage();
echo getTextFromImage($file);
Esempio n. 20
0
 /**
  * @return CustomAssert
  */
 public static function webAssert(\Behat\Mink\Mink $minkContext)
 {
     return new CustomAssert($minkContext->getSession());
 }
 public function giffy()
 {
     if ($this->giffyEnabled) {
         $this->mink->getSession()->getDriver()->giffy();
     }
 }
Esempio n. 22
0
 /**
  *
  * @param string $path url after base - e.g. 'admin'
  */
 protected function visitPath($path)
 {
     $this->mink->getSession()->visit($this->locatePath($path));
     self::printDebugMsg($path);
 }
Esempio n. 23
0
 /**
  * Returns session.
  *
  * @return Session
  */
 protected function getSession()
 {
     return self::$mink->getSession('sess');
 }
 /**
  * @return boolean
  */
 protected function isKernelDriverUsed()
 {
     $driver = $this->mink->getSession()->getDriver();
     return $driver instanceof KernelDriver;
 }
Esempio n. 25
0
 /**
  * @return Session
  */
 public function getSession()
 {
     return $this->mink->getSession();
 }
 /**
  * @param string $elementClass
  *
  * @return Element
  */
 private function instantiateElement($elementClass)
 {
     return new $elementClass($this->mink->getSession(), $this);
 }