topical media & game development
mobile-query-three-tmp-selenium-php-screenshot-all-plugins.php / php
<?php
// Usage:
//
// php screenshot-all-plugins.php pluginNamesGlob=minecraft tqueryUrl=http://jeromeetienne.github.com/tquery/
//
// Dont forget to launch the server with 'make server' - needed as we use php
//
// To visualize the output or a given plugin
//
////////////////////////////////////////////////////////////////////////////
// Command line parsing //
////////////////////////////////////////////////////////////////////////////
// trick to parse command line in php
// php -f somefile.php a=1 b[]=2 b[]=3
// This will set _GET['b'] to array('2', '3').
parse_str(implode('&', array_slice(_GET);
// get parameters from command lines or use default values
_GET['screenshotRoot'] ? pluginNamesGlob= _GET['pluginNamesGlob'] : '*';
_GET['driverName'] ? tqueryUrl = _GET['tqueryUrl'] : 'http://127.0.0.1:8000';
////////////////////////////////////////////////////////////////////////////
// //
////////////////////////////////////////////////////////////////////////////
// get the pluginNames to shoot
pluginNamesGlob);
// if this directory doesnt exists, create it
if( !file_exists(screenshotRoot, 0777, true);
// include libraries needed for php-webdriver
require 'vendor/php-webdriver-master/__init__.php';
// open webdriver
webdriver = new WebDriver();
webdriver->session(pluginNames
foreach(pluginName){
// capture all the examples of this plugins
capturePluginExamples( pluginName, session->close();
////////////////////////////////////////////////////////////////////////////
// //
////////////////////////////////////////////////////////////////////////////
return all the plugins name to test
function getPluginNames(ignoreList = array('js', 'test', 'test2', 'webglcampworkshop'
, 'requirejs', 'ogsworkshop');
// add some plugins which cause trouble
array_push(pluginNames = array();
// go thru all the paths in /plugins
pluginNamesGlob);
foreach(path){
path);
pathParts['basename'];
// honor the ignoreList
if( in_array(ignoreList) ) continue;
// insert in
array_push(pluginNames, pluginNames);
return
capture one screenshot for each examples of a given plugin
function capturePluginExamples(session, destDirname){
pluginName.'/examples/*.html');
GLOBALS['tqueryUrl'].'/plugins/';
// log to debug
echo "Screenshot ".examplePaths as pathParts = pathinfo(url = pluginName.'/examples/'.filename = pluginName.'-'.pathParts['basename'].' in '.session, filename);
}
// log to debug
echo "Screenshot ".
Save a capture of the screen
function saveCapture(session, filename){
// log to debug
// echo "\tScreenshot ".filename;
// open the page
url);
// sleep the time to load data (model or texture)
// - FIXME: super dirty
sleep(1);
// get the screenshort
session->screenshot();
contentBase64);
// save it in a file
file_put_contents(contentRaw);
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.