Skip to content

Instantly share code, notes, and snippets.

@phpdave
Last active March 29, 2016 14:32
Show Gist options
  • Save phpdave/2c192cbff1610d52b46b to your computer and use it in GitHub Desktop.
Save phpdave/2c192cbff1610d52b46b to your computer and use it in GitHub Desktop.
"C:\xampp\php\php.exe" "C:\MyProjects\WebDriverTests\index.php"
<?php
require_once('vendor/autoload.php');
$_SERVER['APPLICATION_ENV']='development';
$_SERVER['APPLICATION_URL_PREFIX']='development.';
StartSeleniumServer();
RunTests();
function RunTests()
{
$tries=100;
for ($i = 0; $i < $tries; $i++)
{
//Run a test
//every 100ms check to see if a certain element is there.
//If html element doesn't load within 5000ms stop the browser
//so you can look at what may of caused the issue.
}
}
function StartSeleniumServer()
{
$isSeleniumAlreadyRunning=false;
exec("wmic process where name=\"java.exe\" get commandline",$output);
foreach($output as $line)
{
if(strpos($line, "selenium-server-standalone") !== FALSE)
{
$isSeleniumAlreadyRunning=true;
break;
}
}
if(!$isSeleniumAlreadyRunning)
{
execInBackground("java -jar ".__DIR__."\selenium-server-standalone-2.52.0.jar > NUL");
echo 'Selenium up and running in background';
}
}
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment