Esempio n. 1
0
<?php

require 'vendor/php-webdriver-master/__init__.php';
$webdriver = new WebDriver();
$session = $webdriver->session('firefox', array());
$url = "http://127.0.0.1:8000/tmp/selenium/php/test-mouse.html";
// open the page
$session->open($url);
$title = $session->title();
$size = $session->window()->size();
$url = $session->url();
var_dump($size);
var_dump($url);
var_dump($title);
//$session->click();
$session->element('css selector', 'body')->click();
// $session->element('css selector','body')->click();
// $session->element('css selector','body')->click();
//$session->element('css selector','body')->moveto();
//$session->element('css selector','body')->click();
//$session->window()->click();
//$session->moveto(array('xoffset' => 3, 'yoffset' => 300));
$session->moveto(array('xoffset' => 10, 'yoffset' => 0));
$session->moveto(array('xoffset' => 10, 'yoffset' => 0));
//$session->moveto(array('element' => $session->element('css selector','body')));
//sleep(4);
// $sScriptResult = $session->execute(array(
// 	'script'	=> 'return window.document.location.hostname',
// 	'args'		=> array(),
// ));
// $sScriptResult = $session->execute(array(
Esempio n. 2
0
<?php

// bootstrap php-webdriver (assuming it is in a directorey "php-webdriver" next to the Menta root directory
require_once dirname(__FILE__) . '/../../php-webdriver/WebDriver/__init__.php';
try {
    # get webdriver
    $webDriver = new WebDriver('http://*****:*****@id="rso"]/li[1]//a');
    printf("Search result: %s\n", $firstResult->text());
    $firstResult->click();
    sleep(5);
    # Go back to search results
    $session->back();
    sleep(5);
    # close session/connection
    $session->close();
Esempio n. 3
0
<?php

require 'vendor/php-webdriver-master/__init__.php';
$webdriver = new WebDriver();
$session = $webdriver->session('chrome', array());
// $session->open("http://google.com");
// $url		= "http://google.com";
// $url		= "http://127.0.0.1:8000/plugins/minecraft/examples/index.html";
// $session->open($url);
// $content_b64	= $session->screenshot();
// $imgData	= base64_decode($content_b64);
// $filename	= "/tmp/screenshot.png";
// file_put_contents($filename, $imgData);
$url = "http://google.com";
$url = "http://127.0.0.1:8000/plugins/minecraft/examples/index.html";
$filename = "/tmp/screenshot.png";
saveCapture($session, $url, $filename);
$session->close();
/**
 * Save a capture of the screen
 */
function saveCapture($session, $url, $filename)
{
    // open the page
    $session->open($url);
    // get the screenshort
    $contentBase64 = $session->screenshot();
    $contentRaw = base64_decode($contentBase64);
    // save it in a file
    file_put_contents($filename, $contentRaw);
}
$driverName = $_GET['driverName'] ? $_GET['driverName'] : 'chrome';
$tqueryUrl = $_GET['tqueryUrl'] ? $_GET['tqueryUrl'] : 'http://127.0.0.1:8000';
//////////////////////////////////////////////////////////////////////////////////
//										//
//////////////////////////////////////////////////////////////////////////////////
// get the pluginNames to shoot
$pluginNames = getPluginNames($pluginNamesGlob);
// if this directory doesnt exists, create it
if (!file_exists($screenshotRoot)) {
    mkdir($screenshotRoot, 0777, true);
}
// include libraries needed for php-webdriver
require 'vendor/php-webdriver-master/__init__.php';
// open webdriver $session
$webdriver = new WebDriver();
$session = $webdriver->session($driverName, array());
// shoot all $pluginNames
foreach ($pluginNames as $pluginName) {
    // capture all the examples of this plugins
    capturePluginExamples($session, $pluginName, $screenshotRoot);
}
// close the session
$session->close();
//////////////////////////////////////////////////////////////////////////////////
//										//
//////////////////////////////////////////////////////////////////////////////////
/**
 * return all the plugins name to test
 */
function getPluginNames($pluginNamesGlob)
{