コード例 #1
0
ファイル: selenium.php プロジェクト: habari/tests
 public function init_webdriver()
 {
     if (empty($this->webdriver)) {
         $this->webdriver = new \WebDriver('localhost', '4444');
         //			$this->webdriver->connect('firefox');
         $this->webdriver->connect('chromium');
     }
 }
コード例 #2
0
 protected function setUp($host = 'localhost', $port = 4444, $browser = 'firefox')
 {
     parent::setUp();
     if (is_array($this->fixtures)) {
         $this->getFixtureManager()->load($this->fixtures);
     }
     $this->webdriver = new WebDriver($host, $port);
     $this->webdriver->connect($browser);
 }
コード例 #3
0
 /**
  * Attempt to connect to Selenium server
  * @return bool TRUE if web driver succesfully initiated
  */
 protected function connect($browser = 'firefox', $host = '127.0.0.1', $port = 4444)
 {
     $this->host = $host;
     $this->port = $port;
     // initiate web driver PHP bindings
     require_once DIR_FRAMEWORK . '/extensions/seleniumWebDriverBindings/phpwebdriver/WebDriver.php';
     // initatie browser
     $this->driver = new WebDriver($this->host, $this->port);
     $this->driver->connect($browser);
     return !empty($this->driver);
 }
コード例 #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();
コード例 #5
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.
*/
require_once "phpwebdriver/WebDriver.php";
$webdriver = new WebDriver('your-username-string:your-access-key-string@ondemand.saucelabs.com', 80);
$webdriver->connect("firefox", "15", array('name' => 'Running a test with php-webdriver-bindings on SauceLabs'));
$webdriver->get("http://google.com");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
if ($element) {
    $element->sendKeys(array("php webdriver"));
    $element->submit();
}
$webdriver->close();
コード例 #6
0
<?php

// Sample WebDriver code - search Google for "Selenium is awesome" and take
// a screenshot.
// You need three things to run this code:
// 1. A copy of chromedriver (from the Selenium downloads.)
// 2. The standalone Selenium server v2.0 running with
//    -Dwebdriver.chrome.driver=${PATH_TO_CHROMEDRIVER}
// 3. A copy of http://code.google.com/p/php-webdriver-bindings/ checked out.
//require_once "..phpwebdriver/WebDriver.php";
require_once "phpwebdriver/WebDriver.php";
$timestamp = time();
//$browsers = array("chrome", "firefox");
//foreach($browsers as $browser) {
$webdriver = new WebDriver("localhost", "4444");
$webdriver->connect();
$webdriver->get("http://google.com");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
$element->sendKeys(array("selenium is awesome"));
$element->submit();
sleep(2);
$webdriver->getScreenshotAndSaveToFile("the_google_{$browser}_{$timestamp}.png");
$webdriver->close();
//}
コード例 #7
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.
*/
require_once "phpwebdriver/WebDriver.php";
$webdriver = new WebDriver("localhost", 4444);
$ffprofile = $webdriver->prepareBrowserProfile("pathToYourFFProfileDirectory");
$webdriver->connect("firefox", "15", array('firefox_profile' => $ffprofile));
$webdriver->get("http://google.com");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
if ($element) {
    $element->sendKeys(array("php webdriver"));
    $element->submit();
}
$webdriver->close();
コード例 #8
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.
*/
require_once "phpwebdriver/WebDriver.php";
$webdriver = new WebDriver("localhost", "4444");
$webdriver->connect("internet explorer");
$webdriver->get("http://google.com");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
if ($element) {
    $element->sendKeys(array("php webdriver"));
    $element->submit();
}
$webdriver->close();