Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Timeouts.php

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

WebDriver

Code

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');
}
RSS feed
Powered by Drupal