<?php
class SessionHelper {
public static $first;
}
SessionHelper::$first = 0;
class S2p_GoogleTest extends PHPUnit_Extensions_Selenium2TestCase{
function setUp(){
if (SessionHelper::$first == 0 )
{
$this->setBrowser("phantomjs");
$this->setBrowserUrl("https://www.google.com/");
$this->setHost("127.0.0.1");
$this->setPort(4444);
$this->shareSession(TRUE);
$this->prepareSession();
SessionHelper::$first = 1;
}
}
public function onNotSuccessfulTest(Exception $e)
{
//$this->getStrategy()->notSuccessfulTest();
throw $e;
}
function testGoogle(){
$this->url('/');
$this->waitUntil(function($testCase) {
try {
$testCase->byCssSelector("form input[autocomplete=\"off\"]");
return true;
} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {}
}, 8000);
$input = $this->byCssSelector("form input[autocomplete=\"off\"]");
$input->value("github");
$input = $this->byCssSelector("form input[type=\"submit\"]");
$input->click();
$this->waitUntil(function($testCase) {
try {
$testCase->byId("res");
return true;
} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {}
}, 8000);
$this->assertTrue((bool)(strpos($this->byTag('body')->text(), 'Build software better, together') !== false));
}
function testGoogle2(){
$this->url('/');
$this->waitUntil(function($testCase) {
try {
$testCase->byCssSelector("form input[autocomplete=\"off\"]");
return true;
} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {}
}, 8000);
$input = $this->byCssSelector("form input[autocomplete=\"off\"]");
$input->value("github");
$input = $this->byCssSelector("form input[type=\"submit\"]");
$input->click();
$this->waitUntil(function($testCase) {
try {
$testCase->byId("res");
return true;
} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {}
}, 8000);
$this->assertFalse((bool)(strpos($this->byTag('body')->text(), 'Build software better, together') !== false));
}
function testGoogle3(){
$this->url('/');
$this->waitUntil(function($testCase) {
try {
$testCase->byCssSelector("form input[autocomplete=\"off\"]");
return true;
} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {}
}, 8000);
$input = $this->byCssSelector("form input[autocomplete=\"off\"]");
$input->value("github");
$input = $this->byCssSelector("form input[type=\"submit\"]");
$input->click();
$this->waitUntil(function($testCase) {
try {
$testCase->byId("res");
return true;
} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {}
}, 8000);
$this->assertTrue((bool)(strpos($this->byTag('body')->text(), 'Build software better, together') !== false));
}
}