omowright 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/TOOLS.md +5 -2
- package/dist/bsk/install-cli.d.ts +2 -0
- package/dist/emulate.d.ts +1 -0
- package/dist/index.js +441 -277
- package/dist/network-snoop.d.ts +1 -0
- package/dist/redact-value.d.ts +7 -0
- package/dist/scroll-collect.d.ts +13 -3
- package/package.json +17 -14
- package/presets/network/SKILL.md +3 -2
- package/presets/visual-browse/SKILL.md +2 -10
- package/skills/omowright/SKILL.md +38 -19
- package/skills/omowright/references/browserskill.md +13 -0
- package/skills/omowright/references/eval-kernel.md +36 -5
- package/skills/omowright/references/frames-layers-human.md +8 -1
- package/skills/omowright/references/quickstart.md +7 -0
package/dist/network-snoop.d.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips a value being entered (fill/type) out of the error its failure raised, so a secret typed
|
|
3
|
+
* into a form never reaches an agent transcript (#335). The layers below (a CDP transport, the
|
|
4
|
+
* BrowserSkill daemon) may quote the command they refused, raw or JSON-escaped, in the message,
|
|
5
|
+
* the stack, a `data` payload or a cause; each is rewritten in place down the cause chain.
|
|
6
|
+
*/
|
|
7
|
+
export declare function redactValue(error: unknown, value: string): unknown;
|
package/dist/scroll-collect.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scroll-driven collection over a network snoop (see ./network-snoop.ts).
|
|
3
|
-
*/
|
|
4
1
|
export interface ScrollPage {
|
|
5
2
|
viewportSize(): {
|
|
6
3
|
width: number;
|
|
7
4
|
height: number;
|
|
8
5
|
} | null | undefined;
|
|
9
6
|
evaluate<T>(pageFunction: () => T): Promise<T>;
|
|
7
|
+
evaluate<T, A>(pageFunction: (arg: A) => T | PromiseLike<T>, arg: A): Promise<T>;
|
|
10
8
|
mouse: {
|
|
11
9
|
move(x: number, y: number): Promise<unknown>;
|
|
12
10
|
wheel(deltaX: number, deltaY: number): Promise<unknown>;
|
|
@@ -14,14 +12,26 @@ export interface ScrollPage {
|
|
|
14
12
|
}
|
|
15
13
|
export interface JsonSnoop {
|
|
16
14
|
popJson(): Iterable<unknown>;
|
|
15
|
+
/** Resolves on the next buffered entry the predicate accepts; rejects after timeoutMs. */
|
|
16
|
+
waitFor(match: (entry: {
|
|
17
|
+
mimeType: string | null;
|
|
18
|
+
}) => unknown, options: {
|
|
19
|
+
timeoutMs: number;
|
|
20
|
+
}): Promise<unknown>;
|
|
17
21
|
}
|
|
18
22
|
export type ScrollMode = "wheel" | "end";
|
|
23
|
+
/** The timer that bounds each round; defaults to the global setTimeout/clearTimeout. */
|
|
24
|
+
export interface ScrollClock {
|
|
25
|
+
setTimeout(callback: () => void, ms: number): unknown;
|
|
26
|
+
clearTimeout(handle: unknown): void;
|
|
27
|
+
}
|
|
19
28
|
export interface CollectWhileScrollingOptions {
|
|
20
29
|
minItems?: number;
|
|
21
30
|
maxScrolls?: number;
|
|
22
31
|
extract?: (json: unknown) => Iterable<unknown>;
|
|
23
32
|
scroll?: ScrollMode;
|
|
24
33
|
settleMs?: number;
|
|
34
|
+
clock?: ScrollClock;
|
|
25
35
|
}
|
|
26
36
|
export interface CollectWhileScrollingResult {
|
|
27
37
|
rounds: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omowright",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "OmOWright browser automation for standard Chromium CDP endpoints.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility-snapshot",
|
|
@@ -46,35 +46,38 @@
|
|
|
46
46
|
"provenance": true
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
|
-
"test": "bun test",
|
|
49
|
+
"test": "bun test --parallel",
|
|
50
50
|
"test:node": "bun scripts/node-test.ts",
|
|
51
51
|
"test:cloak-profile": "bun test test/cloak-profile.test.ts test/cloak-profile.integration.test.ts",
|
|
52
|
-
"typecheck": "
|
|
52
|
+
"typecheck": "bun check --no-script --no-pretty -p tsconfig.json",
|
|
53
53
|
"typecheck:control": "bun scripts/typecheck-control.ts",
|
|
54
54
|
"check": "bun run typecheck:control && bun run typecheck && bun run lint && bun run fmt:check",
|
|
55
|
-
"lint": "oxlint --deny-warnings src bin bridge test scripts",
|
|
55
|
+
"lint": "oxlint --deny-warnings src bin bridge test scripts && bun scripts/lint-ratchet.ts",
|
|
56
|
+
"lint:ratchet:update": "bun scripts/lint-ratchet.ts --update",
|
|
56
57
|
"lint:fix": "oxlint --fix src bin bridge test scripts",
|
|
57
|
-
"fmt": "
|
|
58
|
-
"fmt:check": "
|
|
58
|
+
"fmt": "bun fmt --no-script --write src bin bridge test scripts",
|
|
59
|
+
"fmt:check": "bun fmt --no-script --check src bin bridge test scripts",
|
|
59
60
|
"format": "bun run fmt",
|
|
60
61
|
"format:check": "bun run fmt:check",
|
|
61
62
|
"verify": "bun run check",
|
|
63
|
+
"check:push": "bun run check && bun run build && git diff --exit-code HEAD --",
|
|
64
|
+
"prepare": "husky",
|
|
62
65
|
"build": "bun build.ts",
|
|
63
66
|
"build:extension": "bun bridge/build-extension.ts",
|
|
64
67
|
"prepack": "bun run build",
|
|
65
68
|
"preversion": "git diff --quiet HEAD --"
|
|
66
69
|
},
|
|
67
70
|
"dependencies": {
|
|
68
|
-
"ws": "^8.
|
|
69
|
-
"zod": "^4.6.
|
|
71
|
+
"ws": "^8.23.0",
|
|
72
|
+
"zod": "^4.6.7"
|
|
70
73
|
},
|
|
71
74
|
"devDependencies": {
|
|
72
|
-
"@types/bun": "1.4.
|
|
73
|
-
"acorn": "8.
|
|
74
|
-
"gpt-tokenizer": "4.1.
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
75
|
+
"@types/bun": "1.4.5",
|
|
76
|
+
"acorn": "8.19.0",
|
|
77
|
+
"gpt-tokenizer": "4.1.2",
|
|
78
|
+
"husky": "9.1.7",
|
|
79
|
+
"oxc-parser": "0.159.0",
|
|
80
|
+
"oxlint": "^1.94.0",
|
|
78
81
|
"typescript-5": "npm:typescript@5.9.3"
|
|
79
82
|
},
|
|
80
83
|
"engines": {
|
package/presets/network/SKILL.md
CHANGED
|
@@ -59,7 +59,6 @@ const gen = collectWhileScrolling(page, snoop, {
|
|
|
59
59
|
maxScrolls: 15,
|
|
60
60
|
extract: (json) => json.items ?? [],
|
|
61
61
|
scroll: "wheel", // "end" jumps to the bottom instead
|
|
62
|
-
settleMs: 800,
|
|
63
62
|
});
|
|
64
63
|
let step;
|
|
65
64
|
while (!(step = await gen.next()).done) items.push(step.value);
|
|
@@ -67,7 +66,9 @@ step.value; // { rounds, total, stoppedBecause }
|
|
|
67
66
|
```
|
|
68
67
|
|
|
69
68
|
`for await (const item of gen)` works too when you don't need the return
|
|
70
|
-
value.
|
|
69
|
+
value. A round ends as soon as the next response lands or the page grows;
|
|
70
|
+
`settleMs` (default 800) only bounds a round in which neither happens, so leave
|
|
71
|
+
it alone unless the endpoint is slower than that. The loop drains first, then scrolls, and stops on `minItems`,
|
|
71
72
|
`maxScrolls`, or two consecutive rounds where the document height didn't grow
|
|
72
73
|
(`noGrowth`). The default `extract` accepts bodies that are already arrays.
|
|
73
74
|
|
|
@@ -36,16 +36,8 @@ disagree, every coordinate is wrong by the same constant offset and retrying
|
|
|
36
36
|
repeats the miss. Pin both to one box:
|
|
37
37
|
|
|
38
38
|
```js
|
|
39
|
-
await
|
|
40
|
-
|
|
41
|
-
height: 900,
|
|
42
|
-
deviceScaleFactor: 1,
|
|
43
|
-
mobile: false,
|
|
44
|
-
screenWidth: 1440,
|
|
45
|
-
screenHeight: 900,
|
|
46
|
-
viewport: { x: 0, y: 0, width: 1440, height: 900, scale: 1 },
|
|
47
|
-
});
|
|
48
|
-
const size = await page.refreshViewportSize(); // -> { width: 1440, height: 900 }
|
|
39
|
+
const { repinViewport, DEFAULT_AGENT_VIEWPORT } = await import("omowright");
|
|
40
|
+
const size = await repinViewport(page, DEFAULT_AGENT_VIEWPORT); // -> { width: 1440, height: 900 }
|
|
49
41
|
```
|
|
50
42
|
|
|
51
43
|
Pin every page you act on, including tabs you did not open, then take a fresh
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: omowright
|
|
3
|
-
description: "The default code-driven browser path for interactive browsing work:
|
|
3
|
+
description: "The default code-driven browser path for interactive browsing work: token-efficient a11y snapshots (compactSnapshot drops the refs map), ref-based clicks, condition waits instead of fixed delays, coordinate control (CUA), viewport pinning, CAPTCHA input helpers (reCAPTCHA, Turnstile, hCaptcha, slider, text OCR) with a human fallback, Chrome MV3 APIs, network snoop (read API JSON instead of DOM), flight-recorder trace, OOPIF-aware snapshots, dialog policy, human handoff for login/OTP, device emulation, request routes, and one connectBrowser() entry that picks the engine in order: the user's agent browser (Aside, Ego Lite), the user's own browser through BrowserSkill, then the owned stealth CloakBrowser with zero exposed CDP ports. MUST USE for interactive browser work: scraping, blocked/WAF/JS-rendered pages, logins, the user's logged-in sites and open tabs, extension popups, form filling, screenshots, web QA, CAPTCHAs. The ulw-research browsing lane runs on ultimate-browsing, not this skill."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# OmOWright
|
|
@@ -74,18 +74,37 @@ empty tree, not an error. A search does not move the diff baseline, and `find` c
|
|
|
74
74
|
be combined with `diff`. `maxChars` still caps the whole captured tree before the
|
|
75
75
|
search runs, so leave it off when searching a large page.
|
|
76
76
|
|
|
77
|
+
## Wait for a state, never for a clock
|
|
78
|
+
|
|
79
|
+
**NEVER WRITE A FIXED DELAY** (`Bun.sleep`, `setTimeout`, `waitForTimeout`): it fails on a
|
|
80
|
+
slow page and wastes itself on a fast one. Wait for the state you need, and start the
|
|
81
|
+
wait before the action that causes it.
|
|
82
|
+
|
|
83
|
+
| Waiting for | Call |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| Something appearing or changing in the page | `page.waitForFunction(fn, arg, { timeout })` (options are the THIRD argument), `page.locator(ref).waitFor({ state: "visible" })` |
|
|
86
|
+
| The request an action triggers | `const got = page.waitForResponse(urlOrPredicate)`, act, `await got`; `snoop.waitFor(match)` with a snoop open |
|
|
87
|
+
| A navigation | `page.waitForURL(globOrRegExp)`, `page.waitForLoadState("networkidle")` |
|
|
88
|
+
| A new tab | `page.waitForEvent("popup")`, subscribed before the click |
|
|
89
|
+
| A person (login, OTP, CAPTCHA) | `requestHuman(page, { prompt, until })` |
|
|
90
|
+
|
|
91
|
+
Nothing follows `goto` or `newTab`: both already wait for content. A wait that can outlast
|
|
92
|
+
one tool call (a person, a deploy, a slow job) is not awaited in that call: start it, hand
|
|
93
|
+
its completion to your harness's watcher, keep working. Pattern in
|
|
94
|
+
`references/eval-kernel.md`.
|
|
95
|
+
|
|
77
96
|
## Owned engine: CloakBrowser
|
|
78
97
|
|
|
79
98
|
When omowright owns the browser, use the CloakBrowser binary, not a plain headless shell: most real
|
|
80
99
|
targets sit behind WAFs or bot scoring, and CloakBrowser's source-level
|
|
81
100
|
fingerprint patches (Cloudflare Turnstile, FingerprintJS, BrowserScan) make it
|
|
82
101
|
the safe choice. Plain headless shell is the speed fallback for trivially open
|
|
83
|
-
pages
|
|
84
|
-
`~/Library/Caches/ms-playwright/chromium_headless_shell-*/.../chrome-headless-shell`.
|
|
102
|
+
pages. Take either path from code, never from a guess:
|
|
85
103
|
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
```js
|
|
105
|
+
const { findCloakBrowserPath, detectBrowsers } = await import("omowright");
|
|
106
|
+
const browserPath = findCloakBrowserPath(); // newest ~/.cloakbrowser/chromium-*; throws when none is installed (set CLOAKBROWSER_BIN off macOS)
|
|
107
|
+
const chrome = detectBrowsers().find((b) => b.installed)?.binary; // an installed Chrome-family binary, for the fallback
|
|
89
108
|
```
|
|
90
109
|
|
|
91
110
|
For a reused authenticated profile, use `connectCloakProfile({ profileDir, fingerprintSeed })` from the package (or the `omowright-cloak --profile "$HOME/.local/share/omowright-cloak" --url <url> --once --snapshot` launcher). First use pins a fingerprint seed in a mode-`0600` metadata file inside the mode-`0700` profile; later runs reuse it and **REJECT a conflicting seed** instead of silently changing identity. It passes the fixed `--fingerprint=<seed>` plus the platform flag on every `connectPipe()` launch. The seed is an identity pin, not a credential store.
|
|
@@ -124,18 +143,15 @@ CUA acts in viewport pixels. When the render surface and coordinate space
|
|
|
124
143
|
disagree, every coordinate is off by a constant and retrying repeats the miss:
|
|
125
144
|
|
|
126
145
|
```js
|
|
127
|
-
await
|
|
128
|
-
|
|
129
|
-
height: 900,
|
|
130
|
-
deviceScaleFactor: 1,
|
|
131
|
-
mobile: false,
|
|
132
|
-
screenWidth: 1440,
|
|
133
|
-
screenHeight: 900,
|
|
134
|
-
viewport: { x: 0, y: 0, width: 1440, height: 900, scale: 1 },
|
|
135
|
-
});
|
|
136
|
-
await page.refreshViewportSize(); // -> { width: 1440, height: 900 }
|
|
146
|
+
const { repinViewport, DEFAULT_AGENT_VIEWPORT } = await import("omowright");
|
|
147
|
+
await repinViewport(page, DEFAULT_AGENT_VIEWPORT); // -> { width: 1440, height: 900 }
|
|
137
148
|
```
|
|
138
149
|
|
|
150
|
+
For a device instead of a box, `emulate(page, "iphone-14")` (also `pixel-7`, `ipad-air`,
|
|
151
|
+
`desktop-1440`) sets metrics, touch and user agent together, and
|
|
152
|
+
`page.emulateMedia({ colorScheme })` covers media features. Raw `Emulation.*` CDP is never
|
|
153
|
+
needed for either.
|
|
154
|
+
|
|
139
155
|
Pin every page you act on, including tabs you did not open, then take a fresh
|
|
140
156
|
screenshot — coordinates read off an unpinned screenshot are stale.
|
|
141
157
|
|
|
@@ -166,9 +182,12 @@ Preset and `TOOLS.md` paths are relative to the package root.
|
|
|
166
182
|
their own browser; 1Password sessions are device-bound and never work from
|
|
167
183
|
cookies. Detail in `references/stealth.md`. Cookie reuse is fine for ordinary
|
|
168
184
|
sessions (Grafana, internal tools).
|
|
169
|
-
- **
|
|
170
|
-
map resolves in-page
|
|
171
|
-
|
|
185
|
+
- **Read within a budget.** `compactSnapshot()` before a model reads any snapshot
|
|
186
|
+
(the refs map resolves in-page; it was 7% to 64% of the bytes, measured
|
|
187
|
+
2026-11-09). Check `snapshotTokens(snapshot)` (`{ bytes, estTokens }`) before
|
|
188
|
+
printing a tree you have not measured, and narrow a large one with `find`,
|
|
189
|
+
`selector`, `interactive: true` or `maxChars`. `page.evaluate` returns the
|
|
190
|
+
fields you need, never `innerHTML` or a whole document's `innerText`.
|
|
172
191
|
- **Refs die on every new snapshot.** Pass `page.locator("e1")` straight from the
|
|
173
192
|
latest snapshot; never reuse a ref across snapshots, never put one in CSS.
|
|
174
193
|
- **Refs stay page-level.** Child-frame refs look like `f1e3` and still go to
|
|
@@ -67,6 +67,19 @@ Targets are a ref (`"e3"` / `"@e3"` from `session.observe()` or
|
|
|
67
67
|
`session.snapshot()`), a CSS selector, or `{ captureId, x, y }` from a
|
|
68
68
|
screenshot.
|
|
69
69
|
|
|
70
|
+
On an extension older than 0.4.0 there is no shared control: `cooperate("sync")`
|
|
71
|
+
resolves without a `context_id` and actions run ungated, so the loop above runs
|
|
72
|
+
unchanged there.
|
|
73
|
+
|
|
74
|
+
A `BskSession` is not a page: it has no `goto`, `locator` or `listTargets`.
|
|
75
|
+
Read with `observe({ maxTokens })` first: it is the cheapest read, needs no
|
|
76
|
+
sync context, and its `@eN` refs work inside shadow roots and frames. To wait,
|
|
77
|
+
use `navigate(url, { waitUntil: "networkidle" })` for a page that renders after
|
|
78
|
+
load and `waitForNavigation()` after an action that navigates; for a later
|
|
79
|
+
state, `evaluate` a promise that resolves when the state holds
|
|
80
|
+
(`{ awaitPromise: true, timeoutMs, context }`; `evaluate` is a gated action).
|
|
81
|
+
Never a fixed delay.
|
|
82
|
+
|
|
70
83
|
| Need | Call |
|
|
71
84
|
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
72
85
|
| Navigate / history | `navigate(url, {waitUntil, timeoutMs})`, `back()`, `forward()`, `reload({hard})`, `waitForNavigation()` |
|
|
@@ -7,11 +7,15 @@ parallel. It does not keep child processes alive for you.
|
|
|
7
7
|
**ONLY `globalThis.*` SURVIVES ACROSS CELLS.** Top-level `const`/`let` bindings do
|
|
8
8
|
not; re-import or read from `globalThis` in later cells.
|
|
9
9
|
|
|
10
|
-
**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
**CONNECT ONCE AND KEEP THE HANDLE ON `globalThis`.** A new connect in every
|
|
11
|
+
cell throws away the page state and pays the launch again.
|
|
12
|
+
|
|
13
|
+
**WHETHER A BROWSER SPAWNED IN A CELL OUTLIVES IT DEPENDS ON THE HARNESS.**
|
|
14
|
+
Measured both ways: an older eval kernel killed `Bun.spawn` children with
|
|
15
|
+
SIGKILL at cell completion and lost a `connectPipe` browser between two cells;
|
|
16
|
+
omo's kernel kept a `connectPipe` browser and an unawaited `waitForFunction`
|
|
17
|
+
alive across cells (2026-11-26). A `globalThis.omw` handle whose process is gone
|
|
18
|
+
rejects every call, so probe before reuse. Two patterns hold up everywhere:
|
|
15
19
|
|
|
16
20
|
1. **One cell, whole job.** Connect, act, close in the same cell. Right for any
|
|
17
21
|
job that fits in one cell's runtime; the parallel lanes below are this shape.
|
|
@@ -81,6 +85,33 @@ await omwPage.locator("e1").click();
|
|
|
81
85
|
display(await omwPage.screenshot({ type: "png" })); // display() renders images inline
|
|
82
86
|
```
|
|
83
87
|
|
|
88
|
+
## Waits that outlast a cell
|
|
89
|
+
|
|
90
|
+
A cell that awaits a person, a deploy or a slow job is detached by the harness
|
|
91
|
+
(after 30 s in omo) and then holds the kernel: every later cell queues behind
|
|
92
|
+
it. Subscribe the harness watcher first, start the wait without awaiting it, and
|
|
93
|
+
return:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
const flag = path.join(os.tmpdir(), `omowright-signed-in-${Date.now()}.flag`);
|
|
97
|
+
await tool.monitor({ description: "sign-in finished", path: flag, event: "create" });
|
|
98
|
+
globalThis.omwWait = omwPage
|
|
99
|
+
.waitForFunction(() => document.querySelector("[data-user]") !== null, undefined, { timeout: 600_000 })
|
|
100
|
+
.then(
|
|
101
|
+
() => fs.writeFileSync(flag, "ok"),
|
|
102
|
+
(error) => fs.writeFileSync(flag, `failed: ${error.message}`),
|
|
103
|
+
);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The cell returns at once, the kernel stays free for other cells on the same
|
|
107
|
+
`omwPage`, and the file event wakes the turn on success and on timeout alike,
|
|
108
|
+
so a wait never ends silently. Read the flag, then continue from the live page.
|
|
109
|
+
Measured on 2026-11-26: the event arrived as the page state flipped, and a 2 s
|
|
110
|
+
bound reported `WaitForFunctionTimeoutError` at 2004 ms. `tool.monitor` is omo's
|
|
111
|
+
watcher; in another harness use its file or command watch. The same rule covers
|
|
112
|
+
a dev server or a deploy the page depends on: watch it with a command monitor
|
|
113
|
+
that prints one line when it is ready, never with a loop in a cell.
|
|
114
|
+
|
|
84
115
|
## Parallel lanes (research fan-out)
|
|
85
116
|
|
|
86
117
|
Each lane gets its own browser and profile: no shared state, and the pipe
|
|
@@ -101,6 +101,12 @@ const result = await requestHuman(page, {
|
|
|
101
101
|
if (result.outcome !== "continued") throw new Error(`handoff ${result.outcome}`);
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
**IN AN EVAL CELL, DO NOT `await` THE HANDOFF.** A person takes longer than a
|
|
105
|
+
cell, and an awaited handoff holds the kernel until they finish. Subscribe the
|
|
106
|
+
harness watcher, start `requestHuman(...)` without `await`, write its outcome to
|
|
107
|
+
the watched file in `.then`, and return; the page stays usable from other cells
|
|
108
|
+
meanwhile. Pattern in `eval-kernel.md` (next to this file), "Waits that outlast a cell".
|
|
109
|
+
|
|
104
110
|
The call brings the window to the front, injects a shadow-DOM banner with your
|
|
105
111
|
prompt and a Done button, then polls every `pollMs` for `until` or the button.
|
|
106
112
|
Pass an `AbortSignal` as `signal` to cancel from your side. The banner is
|
|
@@ -129,4 +135,5 @@ fields (`width, height, deviceScaleFactor, mobile, hasTouch, userAgent,
|
|
|
129
135
|
platform`) for a custom device. The original UA is captured on the first call
|
|
130
136
|
per page, so `null` always returns to where you started. Re-snapshot after
|
|
131
137
|
switching: layout changes move refs, and a mobile layout often swaps a nav bar
|
|
132
|
-
for a menu button.
|
|
138
|
+
for a menu button. Media features are separate:
|
|
139
|
+
`page.emulateMedia({ colorScheme: "dark", reducedMotion: "reduce" })`.
|
|
@@ -65,9 +65,16 @@ await page.pdf({ path, format?, margin? });
|
|
|
65
65
|
await page.locator("e1").click(); // ref or CSS
|
|
66
66
|
await page.locator("input[name=q]").fill("text");
|
|
67
67
|
await page.keyboard.press("Enter"); await page.mouse.wheel(0, 400);
|
|
68
|
+
await page.waitForFunction(() => window.ready === true, undefined, { timeout: 10_000 }); // a page state; options are the 3rd argument
|
|
69
|
+
const saved = page.waitForResponse("**/api/cart"); // start the wait, then act, then await it
|
|
70
|
+
await page.locator("e7").click(); await saved;
|
|
71
|
+
await page.waitForURL("**/dashboard"); await page.waitForLoadState("networkidle");
|
|
68
72
|
await page.close();
|
|
69
73
|
```
|
|
70
74
|
|
|
75
|
+
Wait with these, never with a fixed delay; the full table is in `SKILL.md` ("Wait for a
|
|
76
|
+
state, never for a clock").
|
|
77
|
+
|
|
71
78
|
## Snapshot discipline
|
|
72
79
|
|
|
73
80
|
```js
|