summaryrefslogtreecommitdiff
path: root/tests/test_tools/PradoGenericSelenium2Test.php
diff options
context:
space:
mode:
authorDavid <ottodavid@gmx.net>2015-08-06 18:12:45 +0200
committerDavid <ottodavid@gmx.net>2015-08-06 18:14:04 +0200
commitbdfd9f07f17de1751a7e4d94940acb426af4be77 (patch)
tree093d0e40504e0ece761733780934e0d6f09888fe /tests/test_tools/PradoGenericSelenium2Test.php
parent1feb1e95660fdfeb5b6d9e12c6fe085aa2bec5ad (diff)
Fix tests
work around stale references by explicitly waiting
Diffstat (limited to 'tests/test_tools/PradoGenericSelenium2Test.php')
-rwxr-xr-xtests/test_tools/PradoGenericSelenium2Test.php50
1 files changed, 47 insertions, 3 deletions
diff --git a/tests/test_tools/PradoGenericSelenium2Test.php b/tests/test_tools/PradoGenericSelenium2Test.php
index 23dfeb61..535d500d 100755
--- a/tests/test_tools/PradoGenericSelenium2Test.php
+++ b/tests/test_tools/PradoGenericSelenium2Test.php
@@ -22,6 +22,15 @@ class PradoGenericSelenium2Test extends PHPUnit_Extensions_Selenium2TestCase
),
/*
array(
+ 'name' => 'Safari on OSX',
+ 'browserName' => 'safari',
+ 'sessionStrategy' => 'shared',
+ 'host' => '127.0.0.1',
+ 'port' => 4444,
+ ),
+*/
+/*
+ array(
'name' => 'Firefox on WindowsXP',
'browserName' => '*firefox',
'host' => '127.0.0.1',
@@ -89,12 +98,24 @@ class PradoGenericSelenium2Test extends PHPUnit_Extensions_Selenium2TestCase
protected function assertVisible($id)
{
- $this->assertTrue($this->getElement($id)->displayed());
+ try{
+ $this->assertTrue($this->getElement($id)->displayed());
+ } catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
+ //stale element reference. try second time.
+ $this->pause(50);
+ $this->assertTrue($this->getElement($id)->displayed());
+ }
}
protected function assertNotVisible($id)
{
- $this->assertFalse($this->getElement($id)->displayed());
+ try{
+ $this->assertFalse($this->getElement($id)->displayed());
+ } catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
+ //stale element reference. try second time.
+ $this->pause(50);
+ $this->assertFalse($this->getElement($id)->displayed());
+ }
}
protected function assertElementPresent($id)
@@ -227,4 +248,27 @@ class PradoGenericSelenium2Test extends PHPUnit_Extensions_Selenium2TestCase
usleep($msec*1000);
}
-} \ No newline at end of file
+ public function assertSourceContains($text)
+ {
+ $found = strpos($this->source(), $text) !== false;
+ for($i=0;$i<10 && ! $found; $i++) {
+ $this->pause(20);
+ $found = strpos($this->source(), $text) !== false;
+ }
+ $this->assertTrue($found, "Failed asserting that page source contains $text");
+ }
+
+ public function assertSourceNotContains($text)
+ {
+ $found = strpos($this->source(), $text) !== false;
+ for($i=0;$i<10 && $found; $i++) {
+ $this->pause(20);
+ $found = strpos($this->source(), $text) !== false;
+ }
+ $this->assertFalse($found, "Failed asserting that page source does not contain $text");
+ }
+
+
+
+
+}