Permalink
Browse files

- Add ability to slow down execution of Selenium tests.

- Closes #123.
  • Loading branch information...
1 parent 64e8153 commit 34fa4f2a770b6b5d831a793f8d8860f8ed8d68c9 @sebastianbergmann committed Jun 19, 2007
Showing with 31 additions and 1 deletion.
  1. +31 −1 PHPUnit/Extensions/SeleniumTestCase.php
@@ -114,6 +114,12 @@
private $testId = NULL;
/**
+ * @var integer
+ * @access private
+ */
+ private $sleep = 0;
+
+ /**
* @access protected
*/
protected function runTest()
@@ -271,7 +277,21 @@ public function setTimeout($timeout)
}
/**
- * This method (and the next) implement the Selenium RC protocol.
+ * @param integer $seconds
+ * @throws InvalidArgumentException
+ * @access public
+ */
+ public function setSleep($seconds)
+ {
+ if (!is_int($seconds)) {
+ throw new InvalidArgumentException;
+ }
+
+ $this->sleep = $seconds;
+ }
+
+ /**
+ * This method implements the Selenium RC protocol.
*
* @param string $command
* @param array $arguments
@@ -341,6 +361,11 @@ public function __call($command, $arguments)
case 'windowFocus':
case 'windowMaximize': {
$this->doCommand($command, $arguments);
+
+ if ($this->sleep > 0) {
+ sleep($this->sleep);
+ }
+
$this->defaultAssertions($command);
}
break;
@@ -414,6 +439,11 @@ public function __call($command, $arguments)
case 'clickAndWait': {
$this->doCommand('click', $arguments);
$this->doCommand('waitForPageToLoad', array($this->timeout));
+
+ if ($this->sleep > 0) {
+ sleep($this->sleep);
+ }
+
$this->defaultAssertions($command);
}
break;

0 comments on commit 34fa4f2

Please sign in to comment.