The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(ego-browser): address URL wait and locator guidance
0x0d2dd8ca34a15
diff --git a/package/ego-browser/src/driver/waits.test.mjs b/package/ego-browser/src/driver/waits.test.mjsindex 9373c1d..6e779b4 100644--- a/package/ego-browser/src/driver/waits.test.mjs+++ b/package/ego-browser/src/driver/waits.test.mjs@@ -191,6 +191,26 @@ test("waitForURL waitUntil commit returns without waiting for load", async () =>);});+test("waitForURL resolves a matched about:blank without waiting for load", async () => {+ const calls = [];+ const restore = setOverrides({+ cdpOverride: async (method, params) => {+ calls.push({ method, params });+ return { result: { value: "about:blank" } };+ },+ });+ try {+ assert.equal(await waitForURL("about:blank"), true);+ } finally {+ restore();+ }++ assert.equal(+ calls.some(({ method }) => method === "Page.getFrameTree"),+ false,+ );+});+test("waitForRequest matches exact URL and returns a request facade", async () => {const calls = installAutoEgo();try {diff --git a/package/ego-browser/src/driver/waits.ts b/package/ego-browser/src/driver/waits.tsindex c588d8d..97a2e06 100644--- a/package/ego-browser/src/driver/waits.ts+++ b/package/ego-browser/src/driver/waits.ts@@ -102,7 +102,10 @@ export async function waitForURL(url, options: WaitForURLOptions = {}) {);if (urlMatches(current, url)) {const waitUntil = options.waitUntil ?? "load";- return waitUntil === "commit"+ // waitForDocumentLoad treats about:blank as an uncommitted transient+ // document, so a load wait on a matched blank page can never succeed;+ // its empty document is already loaded and has no network traffic.+ return waitUntil === "commit" || current === "about:blank"? true: waitForLoadState(waitUntil, {timeout: Math.max(0, deadline - state.now()),diff --git a/package/ego-browser/src/helpers.ts b/package/ego-browser/src/helpers.tsindex 0fefa5c..a5a1087 100644--- a/package/ego-browser/src/helpers.ts+++ b/package/ego-browser/src/helpers.ts@@ -803,7 +803,7 @@ function createSiteFacade() {const FACADE_HELP: Record<string, string> = {page: 'page: Playwright-style page facade. page.url() asynchronously returns the current URL; always call await page.url() before using the string. Use page.goto(url), page.locator(selector), page.getByText(text), page.getByLabel(text), page.getByPlaceholder(text), page.getByTestId(testId), page.setDefaultTimeout(ms), page.waitForEvent("download"), page.waitForLoadState(state, options), page.waitForURL(url, options), page.waitForRequest(urlOrPredicate, options), page.waitForResponse(urlOrPredicate, options), page.evaluate(expression), page.screenshot(options), page.keyboard.press(key), page.keyboard.type(text), and page.mouse.click(x, y). waitForURL predicates receive URL objects and waitUntil defaults to load.',locator:- "page.locator(selector): returns a strict, auto-waiting locator facade with locator(), getByRole(), getByText(), filter(), first(), nth(index), last(), click(), fill(value), clear(), press(key), check(), selectOption(value), textContent(), innerText(), innerHTML(), isVisible(), isEnabled(), getAttribute(name), screenshot(), count(), evaluate(fn, arg), evaluateAll(fn, arg), and waitFor(options). Narrow multiple matches; use first()/nth() only for confirmed legitimate duplicates.",+ "page.locator(selector): returns an auto-waiting locator facade with locator(), getByRole(), getByText(), filter(), first(), nth(index), last(), click(), fill(value), clear(), press(key), check(), selectOption(value), textContent(), innerText(), innerHTML(), isVisible(), isEnabled(), getAttribute(name), screenshot(), count(), evaluate(fn, arg), evaluateAll(fn, arg), and waitFor(options). getBy*, loc=..., and chained/filtered locators are strict and fail on multiple matches; raw CSS and xpath= selectors act on the first match. Narrow multiple matches; use first()/nth() only for confirmed legitimate duplicates.",browser:"browser: tab facade. Use browser.listTabs(), browser.currentTab(), browser.switchTab(target), browser.openOrReuseTab(url, options), and browser.closeTab(target). Treat targetId as short-lived: obtain and validate it in the current script; switchTab/closeTab refresh the tab list before acting.",taskSpaces:diff --git a/skills/ego-browser/SKILL.md b/skills/ego-browser/SKILL.mdindex 4e6db23..d5e64db 100644--- a/skills/ego-browser/SKILL.md+++ b/skills/ego-browser/SKILL.md@@ -139,7 +139,7 @@ EOF- A `page.waitForURL(...)` predicate receives a `URL` object. Use `url.href`, `url.pathname`, or `url.searchParams`, never `url.includes(...)`. It waits for `load` by default; use `waitUntil: 'commit'` only when intentionally proceeding before load.- `page.waitForURL`, `page.waitForLoadState`, `page.waitForSelector`, locator `waitFor`, and `page.waitForFunction` return a falsy value on timeout. Check the result or immediately verify the required state; do not continue on an unverified assumption.- Start `page.waitForRequest(...)`, `page.waitForResponse(...)`, or another event wait before the triggering action. Network predicates are synchronous and receive Playwright-style request/response facades.-- Single-element actions and required reads are strict and auto-wait. For zero matches, confirm load, active tab, and modal/overlay state before correcting the locator. For multiple matches, inspect `count()` / `allInnerTexts()`, narrow semantically or with `filter(...)`, and use `first()` / `nth()` only after confirming duplicates are legitimate.+- Single-element actions and required reads auto-wait. Only `getBy*`, `loc=...`, and chained or filtered locators are strict and fail on multiple matches; raw CSS and `xpath=` selectors silently act on the first match, so use a strict form for anything destructive. For zero matches, confirm load, active tab, and modal/overlay state before correcting the locator. For multiple matches, inspect `count()` / `allInnerTexts()`, narrow semantically or with `filter(...)`, and use `first()` / `nth()` only after confirming duplicates are legitimate.- Prefer `getByRole`, `getByLabel`, `getByText`, `getByPlaceholder`, `getByTestId`, chained locators, and stable `loc=...` values. Use coordinates only for genuinely visual or canvas-like surfaces.- For lists, extract item objects with `evaluateAll`, `allInnerTexts`, or semantic locators before choosing. Do not choose primarily from a sliced snapshot, a broad free-text regex, or coordinates.- Verify every state-changing action before the Bash command exits. Throw when the required URL, dialog, selected value, item, or data is absent. Do not swallow errors from required actions; reserve `.catch(() => {})` for optional cleanup or non-blocking probes.