/**
  * @param $url
  * @return $this
  * @throws WebDriverException
  */
 public function get($url) {
   $this->dispatch('beforeNavigateTo', $url, $this);
   try {
     $this->driver->get($url);
   } catch (WebDriverException $exception) {
     $this->dispatchOnException($exception);
   }
   $this->dispatch('afterNavigateTo', $url, $this);
   return $this;
 }
 public function open($url, $check_id = '')
 {
     if (strlen($url) > 0 && $url[0] !== '/') {
         $url = '/' . $url;
     }
     $urlToOpen = $this->baseUrl . $url;
     $this->webdriver->get($urlToOpen);
     if (!empty($check_id)) {
         return $this->getElement(LocatorStrategy::id, $check_id);
     } else {
         usleep(self::LOAD_DELAY);
     }
 }
Esempio n. 3
0
 /**
  * @When /I visit the URL (.+)$/
  */
 function i_visit_the_url($url)
 {
     $this->init_webdriver();
     $this->webdriver->get($url);
 }
Esempio n. 4
0
<?php

/*
Copyright 2011 3e software house & interactive agency

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// XAMPP NOTE: First please download Selenium RC (*.jar) from here : http://seleniumhq.org/download/
// XAMPP NOTE: Start the Selenium RC Server via cmd with: java -jar selenium-server-standalone-2.25.0.jar
// XAMPP NOTE: Then start this script with the cmd from here: .\php.exe  -f webdriver-test-example.php
// XAMPP NOTE: This example uses php-webdriver-bindings-0.9.0 (see the folder xampp\pear\phpwebdriver)
require_once "phpwebdriver/WebDriver.php";
require_once "phpwebdriver/LocatorStrategy.php";
$webdriver = new WebDriver("localhost", "4444");
$webdriver->connect("firefox");
$webdriver->get("http://google.com");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
$element->sendKeys(array("selenium google code"));
$element->submit();
$webdriver->close();
Esempio n. 5
0
 protected function open()
 {
     $this->driver->get(getenv('CFX_TEST_WEB_HOST'));
     $this->driver->manage()->addCookie(['name' => 'CFX_TEST_ID', 'value' => $this->testId]);
     $this->navigateTo('');
 }
Esempio n. 6
0
<?php

if (!isset($file)) {
    $file = 'results/rolling_output.csv';
}
echo "Generating snapshots...\n (This process will take a long time. In case of failure make sure you have Mozilla Firefox browser installed on your system and Selenium server installed, properly set up and running on localhost:4444, and check Selenium log file for more info.)\n";
/**
 * Include selenium php webdriver bindings for website snapshot
 */
require_once "phpwebdriver/WebDriver.php";
$webdriver = new WebDriver("localhost", "4444");
$webdriver->connect("firefox");
$fh = fopen($file, 'r');
while (!feof($fh)) {
    $line = fgetcsv($fh, 0, ',', '"');
    if (isset($line[1]) && $line[1] !== '') {
        $webdriver->get("http://" . preg_replace('@http[s]?://@i', '', $line[1]));
        $webdriver->getScreenshotAndSaveToFile("results/snapshots/{$line[0]}.png");
    }
}
$webdriver->close();
<?php

require_once "phpwebdriver/WebDriver.php";
$webdriver = new WebDriver("localhost", "4444");
$webdriver->connect();
$webdriver->get("http://shoppbagg.com");
sleep(5);
$webdriver->getScreenshotAndSaveToFile("shoppbagg.png");
$webdriver->close();