karatelabs/karate · error · DriverException
waitUntil (supplier) timeout
Error message
waitUntil (supplier) timeout
What it means
W3cDriver.waitUntil(Supplier) polls condition.get() every retry interval until the result is truthy or the timeout elapses, then throws a DriverException with the fixed message 'waitUntil (supplier) timeout'. This is the Java-embedded variant used from Java tests/custom code rather than a page JS expression.
Solutions
- Log the supplier's return value each iteration to see why it never becomes truthy
- Increase the timeout via waitUntil(condition, timeout)
- Fix the supplier predicate so it correctly detects the target state
- Ensure whatever the supplier waits on (async job, network event) is actually triggered
Example fix
// before
driver.waitUntil(() -> driver.getUrl().contains("/done")); // nav never happens
// after
driver.click("#finish"); // trigger the navigation first
driver.waitUntil(() -> driver.getUrl().contains("/done"), 30000); Defensive patterns
Strategy: try-catch
Validate before calling
// call condition.get() once yourself and inspect the result before polling Object probe = condition.get();
Try / catch
try {
Object result = driver.waitUntil(condition, timeout);
} catch (DriverException e) {
// log condition.get() result to see why it never turned truthy
} Prevention
- Make the supplier cheap, side-effect free, and loggable
- Trigger the async work the supplier depends on before waiting
- Size the timeout for the slowest expected completion time
When it happens
Trigger: Calling driver.waitUntil(java.util.function.Supplier<Object>) where the supplier keeps returning null/false/0 — e.g. a predicate reading driver state (URL, element count, a flag) that never becomes satisfied within the timeout.
Common situations: Supplier logic bug (always false); condition depends on an external event (websocket, background job) that never fires; timeout too short for the operation being awaited; supplier throws internally and the wrapper keeps polling.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- waitFor timeout
- waitForAny timeout
- waitForEnabled timeout
- waitForResultCount timeout
- waitForText timeout: expected
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/3b545f447832e44e.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/driver/w3c/W3cDriver.java:677
throw new DriverException("waitUntil timeout: " + expression);
}
@Override
public Object waitUntil(java.util.function.Supplier<Object> condition) {
return waitUntil(condition, options.getTimeoutDuration());
}
@Override
public Object waitUntil(java.util.function.Supplier<Object> condition, java.time.Duration timeout) {
long deadline = System.currentTimeMillis() + timeout.toMillis();
while (System.currentTimeMillis() < deadline) {
Object result = condition.get();
if (isTruthy(result)) {
return result;
}
sleep(options.getRetryInterval());
}
throw new DriverException("waitUntil (supplier) timeout");
}
@Override
public List<Element> waitForResultCount(String locator, int count) {
return waitForResultCount(locator, count, options.getTimeoutDuration());
}
@Override
public List<Element> waitForResultCount(String locator, int count, java.time.Duration timeout) {
long deadline = System.currentTimeMillis() + timeout.toMillis();
while (System.currentTimeMillis() < deadline) {
List<Element> results = locateAll(locator);
if (results.size() == count) {
return results;
}
sleep(options.getRetryInterval());
}
throw new DriverException("waitForResultCount timeout: " + locator + " expected count: " + count);View on GitHub (pinned to a22eb90246)