{"record":{"id":"a576bbe668857159","repo":"karatelabs/karate","slug":"waitforenabled-timeout-locator","errorCode":null,"errorMessage":"waitForEnabled timeout: ${locator}","messagePattern":"waitForEnabled timeout: (.+?)","errorType":"exception","errorClass":"DriverException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/driver/w3c/W3cDriver.java","lineNumber":596,"sourceCode":"    @Override\n    public Element waitForEnabled(String locator) {\n        return waitForEnabled(locator, options.getTimeoutDuration());\n    }\n\n    @Override\n    public Element waitForEnabled(String locator, java.time.Duration timeout) {\n        long deadline = System.currentTimeMillis() + timeout.toMillis();\n        while (System.currentTimeMillis() < deadline) {\n            try {\n                if (enabled(locator)) {\n                    return BaseElement.existing(this, locator);\n                }\n            } catch (Exception e) {\n                // Element may not exist yet\n            }\n            sleep(options.getRetryInterval());\n        }\n        throw new DriverException(\"waitForEnabled timeout: \" + locator);\n    }\n\n    @Override\n    public String waitForUrl(String expected) {\n        return waitForUrl(expected, options.getTimeoutDuration());\n    }\n\n    @Override\n    public String waitForUrl(String expected, java.time.Duration timeout) {\n        long deadline = System.currentTimeMillis() + timeout.toMillis();\n        while (System.currentTimeMillis() < deadline) {\n            String url = getUrl();\n            if (url != null && url.contains(expected)) {\n                return url;\n            }\n            sleep(options.getRetryInterval());\n        }\n        throw new DriverException(\"waitForUrl timeout: expected URL containing: \" + expected);","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/w3c/W3cDriver.java#L578-L614","documentation":"W3cDriver.waitForEnabled polls the element's enabled state every retry interval, swallowing per-poll exceptions since the element may not exist yet. If the element never becomes enabled within the timeout, a DriverException naming the locator is thrown.","triggerScenarios":"Calling driver.waitForEnabled(locator) on an element that stays disabled (HTML disabled attribute, form invalid, other field pending) or never appears at all within the timeout.","commonSituations":"Button disabled because a form fails HTML5 validation; disabled until an async validation completes slower than the timeout; element is permanently disabled in the app (test assumption wrong); selector points at a wrapper rather than the input.","solutions":["Inspect the element in devtools to see why it remains disabled (attribute/state)","Complete the precondition that enables it (fill required fields, trigger validation) before waiting","Increase the timeout via waitForEnabled(locator, timeout)","If the element should never enable, adjust the test expectation instead of waiting"],"exampleFix":"// before\ndriver.waitForEnabled('#submit'); // disabled until terms checkbox checked\n// after\ndriver.click('#accept-terms');\ndriver.waitForEnabled('#submit');","handlingStrategy":"try-catch","validationCode":"if (driver.exists(locator) && driver.enabled(locator)) { /* already enabled */ }","typeGuard":null,"tryCatchPattern":"try {\n    driver.waitForEnabled(locator, timeout);\n} catch (DriverException e) {\n    // element stayed disabled; log DOM state of the element\n}","preventionTips":["Satisfy form preconditions (required fields, checkboxes) before waiting for the button","Check why an element is permanently disabled if tests assume otherwise","Target the actual input, not a wrapper element"],"tags":["webdriver","timeout","wait","element-state"],"backgroundTag":"request-timeout","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}