Skip to content

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.

fix(ego-browser): harden fill and transient page actions

Autedc9b8747e154
diff --git a/package/ego-browser/scripts/real-browser-e2e/cases/page-labels.mjs b/package/ego-browser/scripts/real-browser-e2e/cases/page-labels.mjs
index 5b43b69..5b2770b 100644
--- a/package/ego-browser/scripts/real-browser-e2e/cases/page-labels.mjs
+++ b/package/ego-browser/scripts/real-browser-e2e/cases/page-labels.mjs
@@ -410,6 +410,36 @@ export function pageActionsAndPopupCase() {
);
assertEqual((await currentTab()).targetId, source.targetId, "page.fill activates and keeps its page current");
+ await source.evaluate(() => {
+ const editor = document.createElement("div");
+ editor.id = "pointer-activated-editor";
+ editor.contentEditable = "true";
+ editor.textContent = "old editor text";
+ editor.style.cssText =
+ "position:fixed;left:20px;top:160px;width:240px;height:40px;background:white;z-index:1000";
+ let pointerActivated = false;
+ window.__editorPointerActivations = 0;
+ editor.addEventListener("pointerdown", () => {
+ pointerActivated = true;
+ window.__editorPointerActivations += 1;
+ });
+ editor.addEventListener("beforeinput", (event) => {
+ if (!pointerActivated) event.preventDefault();
+ });
+ document.body.append(editor);
+ });
+ await source.fill("#pointer-activated-editor", "accepted after click");
+ assertEqual(
+ await source.evaluate("document.querySelector('#pointer-activated-editor').innerText"),
+ "accepted after click",
+ "page.fill retries a rich editor that requires real pointer activation"
+ );
+ assertEqual(
+ await source.evaluate("window.__editorPointerActivations"),
+ 1,
+ "page.fill uses only one pointer fallback after the standard fill is rejected"
+ );
+
await source.evaluate((popupUrl) => {
const area = document.createElement("div");
area.innerHTML = String.raw\`
diff --git a/package/ego-browser/src/driver/page-actions.ts b/package/ego-browser/src/driver/page-actions.ts
index f088b83..650d01e 100644
--- a/package/ego-browser/src/driver/page-actions.ts
+++ b/package/ego-browser/src/driver/page-actions.ts
@@ -1,5 +1,8 @@
import { runtimeValue } from "../cdp-eval.js";
-import { resolveElementObjectId } from "../element-resolver.js";
+import {
+ ElementResolutionError,
+ resolveElementObjectId,
+} from "../element-resolver.js";
import { RefMap } from "../ref-map.js";
type PageActionServices = {
@@ -59,6 +62,8 @@ type MouseMoveState = PageMouseMoveOptions & {
};
const INPUT_EVENT_DELAY_MS = 25;
+const FILL_VERIFICATION_ATTEMPTS = 5;
+const FILL_VERIFICATION_INTERVAL_MS = 50;
/** Click an element through one explicit target session and Page ref map. */
export async function clickInPage(
@@ -105,6 +110,7 @@ export async function clickInPage(
target.sessionId,
target.objectId,
point.local,
+ count === 1,
);
await dispatchMouseEvent(services, target.sessionId, {
type: "mousePressed",
@@ -198,7 +204,7 @@ export async function fillInPage(
if (this.value !== nextValue) return { error: "malformed value" };
this.dispatchEvent(new Event("input", { bubbles: true, composed: true }));
this.dispatchEvent(new Event("change", { bubbles: true }));
- return { status: "done", cursorPoint: visibleCursorPoint() };
+ return { status: "done", kind: "input", cursorPoint: visibleCursorPoint() };
}
} else if (tag !== "textarea" && !this.isContentEditable) {
return { error: "element is not an input, textarea, or contenteditable element" };
@@ -206,7 +212,8 @@ export async function fillInPage(
this.focus();
const cursorPoint = visibleCursorPoint();
- if (!clearFirst) return { status: "needsinput", cursorPoint };
+ const kind = this.isContentEditable ? "contenteditable" : tag;
+ if (!clearFirst) return { status: "needsinput", kind, cursorPoint };
if (tag === "input" || tag === "textarea") {
this.select();
} else {
@@ -216,20 +223,23 @@ export async function fillInPage(
selection?.removeAllRanges();
selection?.addRange(range);
}
- return { status: "needsinput", cursorPoint };
+ return { status: "needsinput", kind, cursorPoint };
}`;
- const preparation = await services.cdp(
- "Runtime.callFunctionOn",
- {
- functionDeclaration: preparationSource,
- objectId: resolved.objectId,
- arguments: [{ value }, { value: clearFirst }],
- returnByValue: true,
- awaitPromise: false,
- },
- resolved.sessionId,
- );
- const result = runtimeValue(preparation, preparationSource);
+ const prepare = async () => {
+ const preparation = await services.cdp(
+ "Runtime.callFunctionOn",
+ {
+ functionDeclaration: preparationSource,
+ objectId: resolved.objectId,
+ arguments: [{ value }, { value: clearFirst }],
+ returnByValue: true,
+ awaitPromise: false,
+ },
+ resolved.sessionId,
+ );
+ return runtimeValue(preparation, preparationSource);
+ };
+ let result = await prepare();
if (typeof result?.error === "string") {
throw new Error(`page.fill failed: ${result.error}`);
}
@@ -248,36 +258,54 @@ export async function fillInPage(
throw new Error("page.fill received an invalid preparation result");
}
- if (clearFirst && value.length === 0) {
- const keyDown: Record<string, unknown> = {
- type: "rawKeyDown",
- key: "Delete",
- code: "Delete",
- modifiers: 0,
- windowsVirtualKeyCode: 46,
- };
- if ((services.platform ?? process.platform) === "darwin") {
- keyDown.commands = ["deleteForward"];
- }
- await services.cdp("Input.dispatchKeyEvent", keyDown, resolved.sessionId);
- await services.cdp(
- "Input.dispatchKeyEvent",
- {
- type: "keyUp",
- key: "Delete",
- code: "Delete",
- modifiers: 0,
- windowsVirtualKeyCode: 46,
- },
+ await dispatchFillInput(services, resolved.sessionId, value, clearFirst);
+ if (
+ await verifyFilledValue(
+ services,
resolved.sessionId,
- );
- } else if (value.length > 0) {
- await services.cdp(
- "Input.insertText",
- { text: value },
+ resolved.objectId,
+ value,
+ clearFirst,
+ )
+ ) {
+ return;
+ }
+
+ if (result?.kind === "contenteditable") {
+ // Some editors do not install their internal editing state until they
+ // receive a real pointer activation. Retry only after proving that the
+ // ordinary fill had no observable effect, which avoids duplicate input.
+ await clickResolvedElement(
+ services,
resolved.sessionId,
+ resolved.objectId,
+ resolved.frameId,
);
+ result = await prepare();
+ if (typeof result?.error === "string") {
+ throw new Error(`page.fill failed: ${result.error}`);
+ }
+ if (result?.status !== "needsinput") {
+ throw new Error("page.fill received an invalid preparation result");
+ }
+ await dispatchFillInput(services, resolved.sessionId, value, clearFirst);
+ if (
+ await verifyFilledValue(
+ services,
+ resolved.sessionId,
+ resolved.objectId,
+ value,
+ clearFirst,
+ )
+ ) {
+ return;
+ }
}
+
+ const target = result?.kind === "contenteditable" ? "editor" : "field";
+ throw new Error(
+ `page.fill did not accept the text. Click the ${target} and use page.keyboard, then verify the result.`,
+ );
} finally {
await services
.cdp(
@@ -289,6 +317,144 @@ export async function fillInPage(
}
}
+async function dispatchFillInput(
+ services: PageActionServices,
+ sessionId: string,
+ value: string,
+ clearFirst: boolean,
+): Promise<void> {
+ if (clearFirst && value.length === 0) {
+ const keyDown: Record<string, unknown> = {
+ type: "rawKeyDown",
+ key: "Delete",
+ code: "Delete",
+ modifiers: 0,
+ windowsVirtualKeyCode: 46,
+ };
+ if ((services.platform ?? process.platform) === "darwin") {
+ keyDown.commands = ["deleteForward"];
+ }
+ await services.cdp("Input.dispatchKeyEvent", keyDown, sessionId);
+ await services.cdp(
+ "Input.dispatchKeyEvent",
+ {
+ type: "keyUp",
+ key: "Delete",
+ code: "Delete",
+ modifiers: 0,
+ windowsVirtualKeyCode: 46,
+ },
+ sessionId,
+ );
+ return;
+ }
+ if (value.length > 0) {
+ await services.cdp("Input.insertText", { text: value }, sessionId);
+ }
+}
+
+async function verifyFilledValue(
+ services: PageActionServices,
+ sessionId: string,
+ objectId: string,
+ value: string,
+ clearFirst: boolean,
+): Promise<boolean> {
+ const source = `function verifyFilledValue(value, clearFirst) {
+ if (!this.isConnected) return { error: "element is not connected" };
+ const tag = this.nodeName.toLowerCase();
+ const observed = tag === "input" || tag === "textarea"
+ ? this.value
+ : (this.innerText ?? this.textContent ?? "");
+ const normalize = (text) => String(text)
+ .replace(/\\r\\n?/g, "\\n")
+ .replace(/\\u200b/g, "");
+ const actual = normalize(observed);
+ const expected = normalize(value);
+ return {
+ matches: clearFirst ? actual === expected : actual.includes(expected),
+ };
+ }`;
+ let consecutiveMatches = 0;
+ for (let attempt = 0; attempt < FILL_VERIFICATION_ATTEMPTS; attempt += 1) {
+ const response = await services.cdp(
+ "Runtime.callFunctionOn",
+ {
+ functionDeclaration: source,
+ objectId,
+ arguments: [{ value }, { value: clearFirst }],
+ returnByValue: true,
+ awaitPromise: false,
+ },
+ sessionId,
+ );
+ const result = runtimeValue(response, source);
+ if (typeof result?.error === "string") {
+ // Input has already been dispatched, so retrying the whole operation
+ // could duplicate text on a replacement element.
+ throw new Error(`page.fill could not verify the result: ${result.error}`);
+ }
+ if (result?.matches === true) {
+ consecutiveMatches += 1;
+ if (consecutiveMatches === 2) return true;
+ } else {
+ consecutiveMatches = 0;
+ }
+ if (attempt + 1 < FILL_VERIFICATION_ATTEMPTS) {
+ await services.sleep(FILL_VERIFICATION_INTERVAL_MS);
+ }
+ }
+ return false;
+}
+
+async function clickResolvedElement(
+ services: PageActionServices,
+ sessionId: string,
+ objectId: string,
+ frameId?: string,
+): Promise<void> {
+ const point = await resolveElementPoint(
+ services,
+ sessionId,
+ objectId,
+ undefined,
+ frameId,
+ );
+ await dispatchMouseEvent(services, sessionId, {
+ type: "mouseMoved",
+ x: point.x,
+ y: point.y,
+ button: "none",
+ buttons: 0,
+ modifiers: 0,
+ });
+ await assertElementReceivesPointerEvents(
+ services,
+ sessionId,
+ objectId,
+ point.local,
+ true,
+ );
+ await dispatchMouseEvent(services, sessionId, {
+ type: "mousePressed",
+ x: point.x,
+ y: point.y,
+ button: "left",
+ buttons: 1,
+ modifiers: 0,
+ clickCount: 1,
+ });
+ await dispatchMouseEvent(services, sessionId, {
+ type: "mouseReleased",
+ x: point.x,
+ y: point.y,
+ button: "left",
+ buttons: 0,
+ modifiers: 0,
+ clickCount: 1,
+ });
+}
+
/** Move the native mouse over one element in an explicit Page session. */
export async function hoverInPage(
services: PageActionServices,
@@ -595,6 +761,12 @@ async function resolveElementPoint(
);
const point = runtimeValue(response, expression);
if (typeof point?.error === "string") {
+ if (point.error === "element is not visible in the viewport") {
+ throw new ElementResolutionError(
+ `page.click failed: ${point.error}`,
+ "transient",
+ );
+ }
throw new Error(`page.click failed: ${point.error}`);
}
if (!Number.isFinite(point?.x) || !Number.isFinite(point?.y)) {
@@ -647,6 +819,7 @@ async function assertElementReceivesPointerEvents(
sessionId: string,
objectId: string,
point: { x: number; y: number },
+ retryDisconnected = false,
): Promise<void> {
const expression = `function(point) {
${HIT_TARGET_HELPERS}
@@ -669,6 +842,12 @@ async function assertElementReceivesPointerEvents(
);
const result = runtimeValue(response, expression);
if (typeof result?.error === "string") {
+ if (retryDisconnected && result.error === "element is not connected") {
+ throw new ElementResolutionError(
+ `page.click failed: ${result.error}`,
+ "transient",
+ );
+ }
throw new Error(`page.click failed: ${result.error}`);
}
}
diff --git a/package/ego-browser/src/page-model.test.mjs b/package/ego-browser/src/page-model.test.mjs
index 3f49422..03ca786 100644
--- a/package/ego-browser/src/page-model.test.mjs
+++ b/package/ego-browser/src/page-model.test.mjs
@@ -34,8 +34,11 @@ function createFixture(rootDir) {
let timeoutNextMouseDispatch = false;
let dialogOnNextClick = null;
const pendingDialogs = new Map();
- let rejectNextClickPoint = false;
+ let rejectedClickPointsRemaining = 0;
let interceptNextClickPoint = false;
+ let fillElementKind = "input";
+ let fillText = "";
+ let ignoredFillInsertionsRemaining = 0;
let navigateOnNextClickUrl = null;
let elementPresent = true;
let elementVisible = true;
@@ -208,11 +211,26 @@ function createFixture(rootDir) {
type: "object",
value: {
status: "needsinput",
+ kind: fillElementKind,
cursorPoint: { x: 40, y: 60 },
},
},
};
}
+ if (params.functionDeclaration.includes("verifyFilledValue")) {
+ const expected = params.arguments?.[0]?.value ?? "";
+ const clearFirst = params.arguments?.[1]?.value ?? true;
+ return {
+ result: {
+ type: "object",
+ value: {
+ matches: clearFirst
+ ? fillText === expected
+ : fillText.includes(expected),
+ },
+ },
+ };
+ }
if (params.functionDeclaration.includes("checkVisibility")) {
return { result: { type: "boolean", value: elementVisible } };
}
@@ -260,8 +278,8 @@ function createFixture(rootDir) {
},
};
}
- if (rejectNextClickPoint) {
- rejectNextClickPoint = false;
+ if (rejectedClickPointsRemaining > 0) {
+ rejectedClickPointsRemaining -= 1;
return {
result: {
type: "object",
@@ -302,8 +320,20 @@ function createFixture(rootDir) {
};
}
if (method === "Runtime.releaseObject") return {};
- if (method === "Input.insertText") return {};
- if (method === "Input.dispatchKeyEvent") return {};
+ if (method === "Input.insertText") {
+ if (ignoredFillInsertionsRemaining > 0) {
+ ignoredFillInsertionsRemaining -= 1;
+ } else {
+ fillText = params.text;
+ }
+ return {};
+ }
+ if (method === "Input.dispatchKeyEvent") {
+ if (params.type === "rawKeyDown" && params.key === "Delete") {
+ fillText = "";
+ }
+ return {};
+ }
if (method === "DOM.setFileInputFiles") return {};
if (method === "Network.enable") {
networkSessions.add(sessionId);
@@ -474,7 +504,10 @@ function createFixture(rootDir) {
};
},
rejectNextClickPoint() {
- rejectNextClickPoint = true;
+ rejectedClickPointsRemaining = 1;
+ },
+ rejectClickPoints(count) {
+ rejectedClickPointsRemaining = count;
},
interceptNextClickPoint() {
interceptNextClickPoint = true;
@@ -482,6 +515,12 @@ function createFixture(rootDir) {
navigateOnNextClick(url) {
navigateOnNextClickUrl = url;
},
+ configureFill({ kind = "input", initialText = "", ignoreInsertions = 0 }) {
+ fillElementKind = kind;
+ fillText = initialText;
+ ignoredFillInsertionsRemaining = ignoreInsertions;
+ },
+ fillText: () => fillText,
setElementState({ present = true, visible = true }) {
elementPresent = present;
elementVisible = visible;
@@ -1186,6 +1225,79 @@ test("Page fill uses its target session and reports no popup when none opened",
});
});
+test("Page fill retries an unchanged contenteditable once with a real click", async () => {
+ await withFixture(async (fixture) => {
+ const task = taskForRound(fixture, "round-a");
+ const page = await task.openPage("https://example.test/editor");
+ fixture.configureFill({
+ kind: "contenteditable",
+ initialText: "old text",
+ ignoreInsertions: 1,
+ });
+ fixture.calls.length = 0;
+
+ assert.deepEqual(await page.fill("[contenteditable]", "new text"), {});
+ assert.equal(fixture.fillText(), "new text");
+ assert.equal(
+ fixture.calls.filter(
+ ([kind, method]) => kind === "cdp" && method === "Input.insertText",
+ ).length,
+ 2,
+ "the standard input attempt should run once before the pointer fallback",
+ );
+ assert.deepEqual(
+ fixture.calls
+ .filter(
+ ([kind, method]) =>
+ kind === "cdp" && method === "Input.dispatchMouseEvent",
+ )
+ .map(([, , params]) => params.type),
+ ["mouseMoved", "mousePressed", "mouseReleased"],
+ "the fallback should perform exactly one real click",
+ );
+ });
+});
+
+test("Page fill rejects when a contenteditable still ignores the pointer fallback", async () => {
+ await withFixture(async (fixture) => {
+ const task = taskForRound(fixture, "round-a");
+ const page = await task.openPage("https://example.test/editor");
+ fixture.configureFill({
+ kind: "contenteditable",
+ initialText: "old text",
+ ignoreInsertions: 2,
+ });
+
+ await assert.rejects(
+ () => page.fill("[contenteditable]", "new text"),
+ /did not accept the text.*click the editor and use page\.keyboard/i,
+ );
+ assert.equal(fixture.fillText(), "old text");
+ });
+});
+
+test("Page fill does not click a regular input when the site rejects its value", async () => {
+ await withFixture(async (fixture) => {
+ const task = taskForRound(fixture, "round-a");
+ const page = await task.openPage("https://example.test/form");
+ fixture.configureFill({ kind: "input", ignoreInsertions: 1 });
+ fixture.calls.length = 0;
+
+ await assert.rejects(
+ () => page.fill("input[name=email]", "[email protected]"),
+ /did not accept the text/i,
+ );
+ assert.equal(
+ fixture.calls.some(
+ ([kind, method]) =>
+ kind === "cdp" && method === "Input.dispatchMouseEvent",
+ ),
+ false,
+ "only contenteditable elements may receive the pointer fallback",
+ );
+ });
+});
+
test("Page action receipts do not inject observation probes", async () => {
await withFixture(async (fixture) => {
const task = taskForRound(fixture, "round-a");
@@ -2233,15 +2345,51 @@ test("Page click scrolls the element into view before computing its point", asyn
});
});
-test("Page click does not dispatch input when scrolling cannot make the element visible", async () => {
+test("Page click retries a transient visibility change before dispatching input", async () => {
await withFixture(async (fixture) => {
const task = taskForRound(fixture, "round-a");
const page = await task.openPage("https://example.test/first");
fixture.rejectNextClickPoint();
+ assert.deepEqual(await page.click("#temporarily-hidden"), {});
+ assert.equal(
+ fixture.calls.filter(
+ ([kind, method, params]) =>
+ kind === "cdp" &&
+ method === "Runtime.callFunctionOn" &&
+ params.functionDeclaration.includes("getBoundingClientRect"),
+ ).length,
+ 2,
+ );
+ assert(
+ fixture.calls.some(
+ ([kind, method, params]) =>
+ kind === "cdp" &&
+ method === "Input.dispatchMouseEvent" &&
+ params.type === "mouseReleased",
+ ),
+ );
+ });
+});
+
+test("Page click reports a persistent transient state after bounded retries", async () => {
+ await withFixture(async (fixture) => {
+ const task = taskForRound(fixture, "round-a");
+ const page = await task.openPage("https://example.test/first");
+ fixture.rejectClickPoints(3);
+
await assert.rejects(
- () => page.click("#hidden"),
- /element is not visible in the viewport/,
+ () => page.click("#changing"),
+ /page state changed.*new snapshot.*current selector/i,
+ );
+ assert.equal(
+ fixture.calls.filter(
+ ([kind, method, params]) =>
+ kind === "cdp" &&
+ method === "Runtime.callFunctionOn" &&
+ params.functionDeclaration.includes("getBoundingClientRect"),
+ ).length,
+ 3,
);
assert.equal(
fixture.calls.some(
diff --git a/package/ego-browser/src/page-model.ts b/package/ego-browser/src/page-model.ts
index 5db3e53..8a9bfb7 100644
--- a/package/ego-browser/src/page-model.ts
+++ b/package/ego-browser/src/page-model.ts
@@ -57,6 +57,7 @@ import {
type PageWaitForSelectorOptions,
type PageWaitForURLOptions,
} from "./driver/page-waits.js";
+import { ElementResolutionError } from "./element-resolver.js";
import { invokeEgo, isEgoUserControlError } from "./ego-errors.js";
import {
withPage as defaultWithPage,
@@ -83,6 +84,16 @@ type TaskSpaceDescriptor = {
recentTabTitles?: string[];
};
+function isRetryableElementStateError(
+ error: unknown,
+): error is ElementResolutionError {
+ return (
+ error instanceof ElementResolutionError &&
+ error.kind === "transient" &&
+ !error.message.startsWith("Unknown ref:")
+ );
+}
+
type OpenPageOptions = {
as?: string;
timeout?: number;
@@ -261,6 +272,8 @@ export type PageActionReceipt = {
const PAGE_CLOSE_CONFIRM_TIMEOUT_MS = 2_000;
const PAGE_CLOSE_CONFIRM_INTERVAL_MS = 50;
+const PAGE_ACTION_RESOLUTION_ATTEMPTS = 3;
+const PAGE_ACTION_RESOLUTION_RETRY_MS = 50;
const CONTROL_POLL_INTERVAL_MS = 20_000;
const CONTROL_WAIT_TIMEOUT_MS = 600_000;
@@ -1508,11 +1521,29 @@ class Page {
const { receipt } = await this.#runActionBoundary(
page,
async (sessionId) => {
- const refMap = await this.#refMapForAction(page, ...selectors);
- const iframeSessions = await this.#services.ensureFrameSessions(
- page.targetId,
- );
- await operation(sessionId, refMap, iframeSessions);
+ for (
+ let attempt = 1;
+ attempt <= PAGE_ACTION_RESOLUTION_ATTEMPTS;
+ attempt += 1
+ ) {
+ try {
+ const refMap = await this.#refMapForAction(page, ...selectors);
+ const iframeSessions = await this.#services.ensureFrameSessions(
+ page.targetId,
+ );
+ await operation(sessionId, refMap, iframeSessions);
+ return;
+ } catch (error) {
+ if (!isRetryableElementStateError(error)) throw error;
+ if (attempt === PAGE_ACTION_RESOLUTION_ATTEMPTS) {
+ throw new ElementResolutionError(
+ `The page state changed while resolving this action after ${attempt} attempts: ${error.message}. Take a new snapshot and use a current selector.`,
+ "transient",
+ );
+ }
+ await this.#services.sleep(PAGE_ACTION_RESOLUTION_RETRY_MS);
+ }
+ }
},
guardFileChooser,
);
diff --git a/package/ego-browser/src/public-api-schema.ts b/package/ego-browser/src/public-api-schema.ts
index e88c602..03e6e74 100644
--- a/package/ego-browser/src/public-api-schema.ts
+++ b/package/ego-browser/src/public-api-schema.ts
@@ -361,7 +361,7 @@ export const PUBLIC_API_SCHEMA: readonly PublicApiEntry[] = [
{
name: "Page.fill",
signature: "await page.fill(selector, value, { clearFirst? })",
- summary: "Focus and fill an input-like element.",
+ summary: "Focus and fill an input-like element, then verify its value.",
options: {
clearFirst: option("boolean", "Clear the current value before filling."),
},
diff --git a/skills/ego-browser/SKILL.md b/skills/ego-browser/SKILL.md
index eaefc93..7ffe9a7 100644
--- a/skills/ego-browser/SKILL.md
+++ b/skills/ego-browser/SKILL.md
@@ -191,6 +191,9 @@ Refs are scoped to the Page that produced them. Take another snapshot after
navigation, a substantial DOM change, raw CDP, or before reusing a ref in a
later round.
+After opening a menu or dialog that rerenders its contents, take a new snapshot
+before selecting an item from it.
+
### Visual pages: screenshot, mouse, and keyboard
Use a screenshot with mouse and keyboard operations for canvas, rich-text,
@@ -208,6 +211,12 @@ Keyboard names and `+`-separated chords follow Playwright syntax; use
`ControlOrMeta` for portable shortcuts. Low-level mouse and keyboard methods
do not return action receipts, so verify their effect explicitly.
+For rich-text editors and editable table cells, verify the first edit. If
+`fill()` says the target rejected the text, click it, use `page.keyboard`, and
+verify again. Canvas or virtualized grids usually need click plus keyboard or
+paste. Before bulk table entry, test a small 2×2 paste; do not send `Tab` after
+the final cell unless moving focus is intended.
+
### Page JavaScript and CDP
Use `page.evaluate()` for bulk extraction or complex in-page work. It accepts
@@ -243,6 +252,9 @@ for (const popup of receipt.popups ?? []) {
}
```
+A click that opens a new window continues on `task.page(popup.label)`, not on
+the source Page.
+
A popup may initially be `about:blank`; wait for its URL when the destination
matters. Slowly propagating popups appear on the next `pages()` or `tabs()`
reconciliation.
diff --git a/skills/ego-browser/references/api.md b/skills/ego-browser/references/api.md
index 4cd87c9..a85197c 100644
--- a/skills/ego-browser/references/api.md
+++ b/skills/ego-browser/references/api.md
@@ -61,7 +61,7 @@ High-level Page actions return a receipt that may contain `popups` or a synchron
| `await page.dblclick(selector, { button?, delay?, position? })` | `button` (left, middle, right) — Mouse button.<br>`delay` — Input delay in milliseconds.<br>`position` — CSS-pixel offset from the element's top-left corner. | Double-click an element with native CDP input. |
| `await page.hover(selector, { position? })` | `position` — CSS-pixel offset from the element's top-left corner. | Move the mouse over an element. |
| `await page.dragAndDrop(source, target, { button?, sourcePosition?, targetPosition? })` | `button` (left, middle, right) — Mouse button.<br>`sourcePosition` — CSS-pixel offset from the element's top-left corner.<br>`targetPosition` — CSS-pixel offset from the element's top-left corner. | Drag from one element to another. |
-| `await page.fill(selector, value, { clearFirst? })` | `clearFirst` — Clear the current value before filling. | Focus and fill an input-like element. |
+| `await page.fill(selector, value, { clearFirst? })` | `clearFirst` — Clear the current value before filling. | Focus and fill an input-like element, then verify its value. |
| `await page.setInputFiles(selector, pathOrPaths)` | — | Set files on a file input without opening the system chooser. |
| `page.waitForFileChooser({ timeout? })` | `timeout` — Maximum duration in milliseconds. | Wait for a dynamically created file chooser. |
| `await page.scrollBy(deltaY, { deltaX?, behavior? })` | `deltaX` — Horizontal CSS-pixel delta.<br>`behavior` (auto, instant, smooth) — Scroll behavior. | Scroll this Page by CSS-pixel deltas. |