function DocumentElement::waitFor
Same name in other branches
- 9 core/tests/Drupal/Tests/DocumentElement.php \Drupal\Tests\DocumentElement::waitFor()
- 11.x core/tests/Drupal/Tests/DocumentElement.php \Drupal\Tests\DocumentElement::waitFor()
File
-
core/
tests/ Drupal/ Tests/ DocumentElement.php, line 94
Class
- DocumentElement
- Document element.
Namespace
Drupal\TestsCode
public function waitFor($timeout, $callback) {
// Wraps waits in a function to catch curl exceptions to continue waiting.
WebDriverCurlService::disableRetry();
$count = 0;
$wrapper = function (Element $element) use ($callback, &$count) {
$count++;
try {
return call_user_func($callback, $element);
} catch (Exception $e) {
return NULL;
}
};
$result = parent::waitFor($timeout, $wrapper);
if (!$result && $count < 2) {
// If the callback or the system is really slow, then it might have only
// fired once. In this case it is better to trigger it once more as the
// page state has probably changed while the callback is running.
return call_user_func($callback, $this);
}
WebDriverCurlService::enableRetry();
return $result;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.