function Timeouts::wait
helper method to wait until user-defined condition is met
Parameters
callable $callback callback which returns non-false result if wait condition was met:
integer $maxIterations maximum number of iterations:
integer $sleep sleep duration in seconds between iterations:
array $args optional args; if the callback needs $this, then pass it here:
Return value
mixed result from callback function
Throws
\Exception if thrown by callback, or \WebDriver\Exception\Timeout if helper times out
File
-
vendor/
lullabot/ php-webdriver/ lib/ WebDriver/ Timeouts.php, line 50
Class
- Timeouts
- WebDriver\Timeouts class
Namespace
WebDriverCode
public function wait($callback, $maxIterations = 1, $sleep = 0, $args = array()) {
$i = max(1, $maxIterations);
while ($i-- > 0) {
$result = call_user_func_array($callback, $args);
if ($result !== false) {
return $result;
}
// don't sleep on the last iteration
$i && sleep($sleep);
}
throw WebDriverException::factory(WebDriverException::TIMEOUT, 'wait() method timed out');
}