karatelabs/karate · error
retry FAILED after attempts: |
Error message
retry FAILED after {} attempts: {} | {} What it means
WARN log emitted when the CDP driver's retry helper exhausts all maxAttempts without the condition ever becoming true. The message includes the driver state snapshot (getDriverState()) to aid diagnosis. The helper returns false to its caller, which typically translates into a failed wait/timeout assertion in the test.
Solutions
- Read the appended driver state in the log to see where the driver was stuck (URL, targets, readiness).
- Verify the selector/URL/frame the condition targets is actually correct in the app under test.
- Increase the retry timeout/interval if the app legitimately needs longer.
- Check Chrome/network health; a crashed or unresponsive browser will never satisfy the condition.
Example fix
// before: relying on default retries driver.retry(interval, count, condition); // after: give a legitimately slow app more budget driver.retry(2000, 15, condition); // 30s total instead of default
Defensive patterns
Strategy: retry
Validate before calling
// Java-side guard before invoking a wait that relies on the retry helper
if (!driverRetry.waitFor(description, condition, maxAttempts, interval)) {
throw new AssertionError("condition never satisfied: " + description + " | driver state: " + driverState);
} Try / catch
// treat the false return as a timeout failure
catch (AssertionError e) {
logger.error("retry exhausted: {}", e.getMessage()); // inspect logged getDriverState()
} Prevention
- Always read the driver-state snapshot in the log — it usually reveals whether the page, URL, or target was wrong.
- Budget timeouts against slow CI machines, not local laptops.
- Validate selectors/frames against the real app before long retry loops.
When it happens
Trigger: The Supplier<Boolean> condition never returned true within maxAttempts × interval milliseconds — e.g. element never appeared, navigation never completed, expected driver state never reached.
Common situations: Wrong selector or frame; page crashed or navigated away; network failure loading the app; Chrome hung; timeout budget simply too small for a heavy page.
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.
Related errors
- element not found after
- Page.navigate timed out, retrying
- retry started: (max attempts, ms interval)
- retry failed after attempts:
- CDP timeout for
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/aa72955f7ac30e90.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java:4290
// Retry loop
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
// Abort on interruption instead of degrading into a busy spin: sleep()
// preserves the interrupt flag, so every later sleep would return
// instantly and the remaining attempts would hammer CDP back-to-back.
if (Thread.currentThread().isInterrupted()) {
logger.warn("retry aborted (thread interrupted): {}", description);
return false;
}
sleep(interval);
if (Boolean.TRUE.equals(condition.get())) {
logger.warn("retry succeeded after {} attempt(s): {}", attempt, description);
return true;
}
logger.warn("retry attempt {}/{} failed for: {}", attempt, maxAttempts, description);
}
// Log failure with driver state for diagnostics
logger.warn("retry FAILED after {} attempts: {} | {}", maxAttempts, description, getDriverState());
return false;
}
/**
* Centralized retry mechanism using default options.
*/
private boolean retry(String description, Supplier<Boolean> condition) {
return retry(description, condition, options.getRetryCount(), options.getRetryInterval());
}
/**
* Get current driver state for diagnostic logging.
* Captures key state that helps debug flaky test failures.
*/
private String getDriverState() {
StringBuilder sb = new StringBuilder();
sb.append("url=");
try {View on GitHub (pinned to a22eb90246)