{"record":{"id":"3690636ca99ab8c8","repo":"karatelabs/karate","slug":"no-page-found-matching-titleorurl","errorCode":null,"errorMessage":"no page found matching: ${titleOrUrl}","messagePattern":"no page found matching: (.+?)","errorType":"exception","errorClass":"DriverException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java","lineNumber":3961,"sourceCode":"        // Retry the enumeration: Target.getTargets can transiently lag a freshly\n        // opened/closed tab, or report a page whose url/title field is not yet\n        // populated while it is still loading - especially under parallel load. A\n        // single-shot lookup then spuriously throws \"no page found\" (observed flaky\n        // on tab-switch under CI). Poll within the same budget as other auto-waits.\n        int interval = fastPollInterval();\n        int maxAttempts = fastPollAttempts();\n        for (int attempt = 0; ; attempt++) {\n            String targetId = findPageTarget(titleOrUrl);\n            if (targetId != null) {\n                activateTarget(targetId);\n                return;\n            }\n            if (attempt >= maxAttempts) {\n                break;\n            }\n            sleep(interval);\n        }\n        throw new DriverException(\"no page found matching: \" + titleOrUrl);\n    }\n\n    /**\n     * Find a page target whose title or URL contains the given substring, or null.\n     */\n    private String findPageTarget(String titleOrUrl) {\n        for (Map<String, Object> target : pageTargets()) {\n            String title = (String) target.get(\"title\");\n            String url = (String) target.get(\"url\");\n            if ((title != null && title.contains(titleOrUrl)) ||\n                    (url != null && url.contains(titleOrUrl))) {\n                return (String) target.get(\"targetId\");\n            }\n        }\n        return null;\n    }\n\n    /**","sourceCodeStart":3943,"sourceCodeEnd":3979,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java#L3943-L3979","documentation":"A page-switch helper (switchPage-style polling over CDP targets) exhausts its retry attempts without finding a page target whose title or URL contains the given substring, then throws this DriverException. Karate retries at a fast poll interval so freshly opened tabs are picked up, but if no matching target appears the wait is abandoned.","triggerScenarios":"switchPage(titleOrUrl) (or the matching driver keyword) called with a substring that matches no open tab's title or URL — the tab never opened, closed before the switch, or the title/URL differs from the argument.","commonSituations":"window.open / target=_blank link never fired (popup blocked); new tab URL is an exact match only but the argument is a partial string from an older app version; tab closed by the app before the poll; typos or case-sensitivity in the substring.","solutions":["List current targets (getPages / Target.getTargets via devtools) and match the argument against actual titles/URLs","Increase the switch timeout/retry config so slow popups are covered","Ensure the action that opens the new tab actually executed (check for popup blockers)","Pass a stable substring of the final URL (after redirects) rather than the initial about:blank or transient title"],"exampleFix":"// before\ndriver.switchPage(\"Reports Dashboard\");\n// after\nlogger.debug(\"pages={}\", driver.getPages());\nString url = (String) driver.script(\"window.location.href\");\ndriver.switchPage(url.contains(\"reports\") ? \"reports\" : \"Reports Dashboard\");","handlingStrategy":"retry","validationCode":"List<String> pages = driver.getPages();\nif (pages.isEmpty()) { throw new IllegalStateException(\"no page targets open\"); }","typeGuard":null,"tryCatchPattern":"try {\n    driver.switchPage(\"Reports Dashboard\");\n} catch (DriverException e) {\n    logger.error(\"no matching tab; open targets={}\", driver.getPages());\n    // one retry in case the popup was slow\n    karate.call.sleep(1000);\n    driver.switchPage(\"Reports\");\n}","preventionTips":["Switch by a stable substring of the final URL, not transient titles","Confirm the popup-opening action succeeded (popup blockers!) before switching","Inspect getPages()/targets when a match fails instead of guessing strings"],"tags":["driver","page-switch","tab","target-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}