@zenera/browser 1.3.39 → 1.3.40
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/dist/session.d.ts +5 -0
- package/dist/session.js +14 -0
- package/package.json +3 -3
package/dist/session.d.ts
CHANGED
|
@@ -69,6 +69,11 @@ export declare class PageSession {
|
|
|
69
69
|
snapshot(maxLines?: number): Promise<string>;
|
|
70
70
|
/** A ref from the last snapshot (`e5`, `@e5`), or a Playwright selector. */
|
|
71
71
|
locate(target: string): Locator;
|
|
72
|
+
/**
|
|
73
|
+
* locate, refusing at once a ref the last snapshot does not have (the page changed, or no
|
|
74
|
+
* snapshot was taken) rather than waiting for it to appear.
|
|
75
|
+
*/
|
|
76
|
+
element(target: string): Promise<Locator>;
|
|
72
77
|
setView(opts: {
|
|
73
78
|
width?: number;
|
|
74
79
|
dark?: boolean;
|
package/dist/session.js
CHANGED
|
@@ -14,6 +14,7 @@ export const PREVIEW = { width: 1200, height: 630 };
|
|
|
14
14
|
const MAX_PARTS = 8;
|
|
15
15
|
const PANEL = { width: WIDTH_PRESETS.panel, height: 900 };
|
|
16
16
|
const QUIET_MS = 500;
|
|
17
|
+
const ACTION_TIMEOUT_MS = 10_000;
|
|
17
18
|
const CDN_HOSTS = new Set(VIEW_CDNS.map((u) => new URL(u).host));
|
|
18
19
|
export class BrowserMissing extends Error {
|
|
19
20
|
}
|
|
@@ -119,6 +120,8 @@ export class PageSession {
|
|
|
119
120
|
deviceScaleFactor: 1,
|
|
120
121
|
serviceWorkers: 'block',
|
|
121
122
|
});
|
|
123
|
+
// An action on what is not there (yet) fails in 10 s, not Playwright's 30.
|
|
124
|
+
context.setDefaultTimeout(ACTION_TIMEOUT_MS);
|
|
122
125
|
const page = await context.newPage();
|
|
123
126
|
const session = new PageSession(b, context, page, host, browser === undefined);
|
|
124
127
|
await session.#wire();
|
|
@@ -293,6 +296,17 @@ export class PageSession {
|
|
|
293
296
|
? this.page.getByRef(target.replace(/^@/, ''))
|
|
294
297
|
: this.page.locator(target);
|
|
295
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* locate, refusing at once a ref the last snapshot does not have (the page changed, or no
|
|
301
|
+
* snapshot was taken) rather than waiting for it to appear.
|
|
302
|
+
*/
|
|
303
|
+
async element(target) {
|
|
304
|
+
const l = this.locate(target);
|
|
305
|
+
if (isRef(target) && (await l.count()) === 0) {
|
|
306
|
+
throw new Error(`no element ${target} in the page's last snapshot: take a new one (zen page snapshot) and use its refs`);
|
|
307
|
+
}
|
|
308
|
+
return l;
|
|
309
|
+
}
|
|
296
310
|
async setView(opts) {
|
|
297
311
|
if (opts.width !== undefined) {
|
|
298
312
|
const size = this.page.viewportSize() ?? PANEL;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenera/browser",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.40",
|
|
4
4
|
"description": "An html page in a real browser, served as a zen chat serves it: checked for errors, driven, photographed.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"playwright",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"prepack": "tsc -b"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@zenera/engine": "^1.3.
|
|
45
|
-
"@zenera/sandbox": "^1.3.
|
|
44
|
+
"@zenera/engine": "^1.3.40",
|
|
45
|
+
"@zenera/sandbox": "^1.3.40",
|
|
46
46
|
"playwright-core": "1.65.1"
|
|
47
47
|
}
|
|
48
48
|
}
|