private function DrupalSelenium2Driver::waitFor in Drupal 10
Waits for a callback to return a truthy result and returns it.
Parameters
int|float $timeout: Maximal allowed waiting time in seconds.
callable $callback: Callback, which result is both used as waiting condition and returned. Will receive reference to `this driver` as first argument.
Return value
mixed The result of the callback.
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ DrupalSelenium2Driver.php, line 200
Class
- DrupalSelenium2Driver
- Provides a driver for Selenium testing.
Namespace
Drupal\FunctionalJavascriptTestsCode
private function waitFor($timeout, callable $callback) {
$start = microtime(TRUE);
$end = $start + $timeout;
do {
$result = call_user_func($callback, $this);
if ($result) {
break;
}
usleep(10000);
} while (microtime(TRUE) < $end);
return $result;
}