@itmetsam/samurai-framework 0.22.10 → 0.22.11
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/browser/page-actions.d.ts +151 -0
- package/dist/browser/page-actions.js +197 -0
- package/dist/browser/page-core.d.ts +80 -0
- package/dist/browser/page-core.js +150 -0
- package/dist/browser/page-locating.d.ts +37 -0
- package/dist/browser/page-locating.js +58 -0
- package/dist/browser/page-observing.d.ts +120 -0
- package/dist/browser/page-observing.js +194 -0
- package/dist/browser/page.d.ts +7 -358
- package/dist/browser/page.js +2 -582
- package/dist/locator/locator-element-methods.d.ts +169 -0
- package/dist/locator/locator-element-methods.js +228 -0
- package/dist/locator/locator.d.ts +7 -161
- package/dist/locator/locator.js +4 -223
- package/package.json +1 -1
package/dist/browser/page.d.ts
CHANGED
|
@@ -1,374 +1,23 @@
|
|
|
1
|
-
import type { APIRequestContext } from "../request/api-request-context.js";
|
|
2
|
-
import Locator from "../locator/locator.js";
|
|
3
|
-
import type { FilterOptions } from "../locator/filter-step.js";
|
|
4
|
-
import type { RoleOptions } from "../locator/role-locator.js";
|
|
5
|
-
import type { ExactOption, TextOptions } from "../locator/selector.js";
|
|
6
|
-
import type { NetworkRequest } from "../network/network-tracker.js";
|
|
7
1
|
import type { Recorder, RecorderOptions } from "../recorder/recorder.js";
|
|
8
|
-
import {
|
|
9
|
-
import type {
|
|
10
|
-
import {
|
|
11
|
-
import type { RuntimeUseOptions } from "../types/use.js";
|
|
12
|
-
import type { Download } from "./download.js";
|
|
13
|
-
import type { FileChooser } from "./file-chooser.js";
|
|
14
|
-
import { type ScreenshotOptions } from "./screenshot.js";
|
|
15
|
-
import type { Evidence } from "./evidence.js";
|
|
16
|
-
import type { LogRecord, PageError } from "./page-logs.js";
|
|
17
|
-
import type { RouteHandler } from "../network/router.js";
|
|
18
|
-
import { Response } from "../network/response.js";
|
|
19
|
-
import type { NetworkMatch } from "../network/network-wait.js";
|
|
20
|
-
import type { UrlPattern } from "../network/url-match.js";
|
|
2
|
+
import { PageObserving } from "./page-observing.js";
|
|
3
|
+
import type { PageEventName, WaitableEventName, WaitForEventOptions, WaitOptions } from "./page-events.js";
|
|
4
|
+
import type { PageSettings, ReadinessState } from "./page-settings.js";
|
|
21
5
|
import type { LoadState, NavigateOptions, NavigationResult } from "./page-navigation.js";
|
|
22
|
-
|
|
23
|
-
import Mouse from "./mouse.js";
|
|
24
|
-
import { type PageEventName, type PageEvents, type WaitableEventName, type WaitForEventOptions, type WaitOptions } from "./page-events.js";
|
|
6
|
+
/** @public */
|
|
25
7
|
export type { PageEventName, WaitableEventName, WaitForEventOptions, WaitOptions, };
|
|
26
|
-
|
|
8
|
+
/** @public */
|
|
27
9
|
export type { PageSettings, ReadinessState };
|
|
28
|
-
|
|
29
|
-
import type { PreloadHandle } from "../script/preload.js";
|
|
30
|
-
import type { BiDiConnector } from "../transport/bidi-connection.js";
|
|
31
|
-
import type { PageFunction } from "../script/call-function.js";
|
|
32
|
-
import type { BrowsingContext } from "../types/bidi-modules/browsing-context.js";
|
|
10
|
+
/** @public */
|
|
33
11
|
export type { LoadState, NavigateOptions, NavigationResult };
|
|
34
|
-
export default class Page {
|
|
35
|
-
private biDiConnector;
|
|
36
|
-
private id;
|
|
37
|
-
private lazyTree;
|
|
38
|
-
private helperRealm;
|
|
39
|
-
private initScripts;
|
|
40
|
-
private pageConfig;
|
|
41
|
-
private locators;
|
|
42
|
-
/** Real key input to whatever has focus: `press` (also chords such as `Control+a`), `down`, `up`, `type`, `insertText` */
|
|
43
|
-
readonly keyboard: Keyboard;
|
|
44
|
-
/** Real pointer input at viewport coordinates: `move`, `down`, `up`, `click`, `dblclick`, `wheel` */
|
|
45
|
-
readonly mouse: Mouse;
|
|
46
|
-
private pageEvents;
|
|
47
|
-
private documents;
|
|
48
|
-
private nav;
|
|
49
|
-
private net;
|
|
50
|
-
private dialogs;
|
|
51
|
-
private logging;
|
|
52
|
-
private isClosed;
|
|
53
|
-
private browserContext;
|
|
54
|
-
private transfers;
|
|
55
|
-
private evidence;
|
|
56
|
-
private viewport;
|
|
57
|
-
/** `settings` override what `samurai.config.ts` says; without them the config is read when needed */
|
|
58
|
-
constructor(biDiConnector: BiDiConnector, contextId: string, settings?: PageSettings);
|
|
59
|
-
/** The BiDi browsing context id of this page's top-level context */
|
|
60
|
-
get contextId(): BrowsingContext;
|
|
61
|
-
/** The context tree, created on first use and shared by everything that needs to attribute frame events to this page */
|
|
62
|
-
tree(): Promise<ContextTree>;
|
|
63
|
-
/**
|
|
64
|
-
* Locates elements on the page. An xpath (`//x`, `/html/body`, `(//x)[2]`, `./x`, `xpath=…`, or an older
|
|
65
|
-
* relative one such as `a[@id='x']`) or a css selector (`input[name='x']`, `a, button`, `css=…`).
|
|
66
|
-
* `options` filter the matches, as `locator.filter()` does
|
|
67
|
-
*/
|
|
68
|
-
locator(selector: string, options?: FilterOptions<Locator>): Locator;
|
|
69
|
-
/**
|
|
70
|
-
* Makes this page's locators strict (or not): an action or read on a locator matching several elements then
|
|
71
|
-
* throws `name(): strict mode violation, N elements match ...` instead of using the first. `undefined` goes back
|
|
72
|
-
* to config `use.strictSelectors` (off unless set). Applies to locators made afterwards and to earlier ones that have not
|
|
73
|
-
* run an action or read yet: a locator keeps the answer it got at its first one
|
|
74
|
-
*/
|
|
75
|
-
setStrictSelectors(enabled: boolean | undefined): void;
|
|
76
|
-
/** Locates elements with a CSS selector */
|
|
77
|
-
getByCss(css: string): Locator;
|
|
78
|
-
/** Locates elements by their text: an exact match unless `match: "partial"` or `exact: false`; a RegExp is tested as written (see `TextOptions`) */
|
|
79
|
-
getByText(text: string | RegExp, options?: TextOptions): Locator;
|
|
80
|
-
/** Locates form controls by their label text: an exact match unless `match: "partial"` or `exact: false`; a RegExp is tested as written */
|
|
81
|
-
getByLabel(text: string | RegExp, options?: TextOptions): Locator;
|
|
82
|
-
/** Locates elements by their `placeholder` (see `TextOptions` for `exact` and RegExp) */
|
|
83
|
-
getByPlaceholder(text: string | RegExp, options?: ExactOption): Locator;
|
|
84
|
-
/** Locates elements by their `alt` text (images, areas, image inputs) */
|
|
85
|
-
getByAltText(text: string | RegExp, options?: ExactOption): Locator;
|
|
86
|
-
/** Locates elements by their `title` attribute */
|
|
87
|
-
getByTitle(text: string | RegExp, options?: ExactOption): Locator;
|
|
88
|
-
/** Locates elements by their `data-testid` attribute */
|
|
89
|
-
getByTestId(testId: string): Locator;
|
|
90
|
-
/** Locates elements by ARIA role and, optionally, accessible name and state (see `RoleOptions`) */
|
|
91
|
-
getByRole(role: string, options?: RoleOptions): Locator;
|
|
92
|
-
/**
|
|
93
|
-
* Runs `script` before any page script in every document this page loads from now on, and once in
|
|
94
|
-
* the document that is loaded now. It runs in the page's own realm, so the page sees what it sets.
|
|
95
|
-
* A function receives `arg` (which must be JSON-serializable) as its only argument;
|
|
96
|
-
* a string is script source (statements) and takes no argument.
|
|
97
|
-
* @example
|
|
98
|
-
* await page.addInitScript(() => { window.__testMode = true; });
|
|
99
|
-
* await page.addInitScript((flags) => { window.flags = flags; }, { beta: true });
|
|
100
|
-
*/
|
|
101
|
-
addInitScript(script: string | ((arg?: any) => void), arg?: unknown): Promise<PreloadHandle>;
|
|
12
|
+
export default class Page extends PageObserving {
|
|
102
13
|
/**
|
|
103
14
|
* Starts recording what a person does in the page as steps (see `Recorder`). The page must be driven by
|
|
104
15
|
* a person; stop with `recorder.stop()`.
|
|
105
16
|
*/
|
|
106
17
|
record(options: RecorderOptions): Promise<Recorder>;
|
|
107
|
-
/** Removes everything the page registered in the browser: init scripts, framework helpers and event subscriptions */
|
|
108
|
-
dispose(): Promise<void>;
|
|
109
|
-
/** Sets the base that relative `goto` URLs resolve against; `undefined` falls back to the run's baseURL */
|
|
110
|
-
setBaseURL(url: string | undefined): void;
|
|
111
|
-
/** @internal The full URL `goto` would navigate to: a URL starting with "/", "./" or "../" resolves against the base URL, others stay as given. `method` names the caller in the error */
|
|
112
|
-
resolveURL(url: string, method?: string): string;
|
|
113
|
-
/**
|
|
114
|
-
* Navigates like `navigateTo`, but a URL starting with "/", "./" or "../" resolves against the base URL
|
|
115
|
-
* (`setBaseURL`, else the environment's `baseURL`).
|
|
116
|
-
* @example
|
|
117
|
-
* await page.goto("/products");
|
|
118
|
-
* await page.goto("https://example.com", { wait: "interactive" });
|
|
119
|
-
*/
|
|
120
|
-
goto(url: string, options?: NavigateOptions): Promise<NavigationResult>;
|
|
121
|
-
/**
|
|
122
|
-
* Navigates to `url` and resolves when the page reached `wait` (default "complete", the load event).
|
|
123
|
-
* A URL without a scheme gets `https://`. Throws NavigationError when the navigation fails or takes too long.
|
|
124
|
-
* The positional form `navigateTo(url, wait, protocol)` still works.
|
|
125
|
-
* @example
|
|
126
|
-
* await page.navigateTo("example.com");
|
|
127
|
-
* await page.navigateTo("localhost:3000", { wait: "interactive", protocol: "http" });
|
|
128
|
-
*/
|
|
129
|
-
navigateTo(url: string, options?: NavigateOptions | ReadinessState, protocol?: "http" | "https"): Promise<NavigationResult>;
|
|
130
|
-
/**
|
|
131
|
-
* Reloads the page and resolves when it reached `wait` (default like `navigateTo`). Firefox does not support
|
|
132
|
-
* `ignoreCache`; asking for it throws UnsupportedOperationError.
|
|
133
|
-
*/
|
|
134
|
-
reload(options?: {
|
|
135
|
-
wait?: ReadinessState;
|
|
136
|
-
timeout?: number;
|
|
137
|
-
ignoreCache?: boolean;
|
|
138
|
-
}): Promise<NavigationResult>;
|
|
139
|
-
/** Goes back one entry in the history. False when there is none to go back to */
|
|
140
|
-
goBack(): Promise<boolean>;
|
|
141
|
-
/** Goes forward one entry in the history. False when there is none */
|
|
142
|
-
goForward(): Promise<boolean>;
|
|
143
|
-
/** The URL of the page now */
|
|
144
|
-
url(): Promise<string>;
|
|
145
|
-
/**
|
|
146
|
-
* Waits until the URL matches `url` (a string equals it, or with `*` / `**` is a glob; a RegExp is tested on it;
|
|
147
|
-
* a function gets it as a `URL`), then until the page reached `waitUntil` (default "load"). Also sees `pushState`.
|
|
148
|
-
* @example
|
|
149
|
-
* await page.getByRole("button", { name: "Sign in" }).click();
|
|
150
|
-
* await page.waitForURL("**\/dashboard");
|
|
151
|
-
*/
|
|
152
|
-
waitForURL(url: UrlPattern | ((url: URL) => boolean), options?: {
|
|
153
|
-
timeout?: number;
|
|
154
|
-
waitUntil?: LoadState;
|
|
155
|
-
}): Promise<void>;
|
|
156
|
-
/** The markup of the document now, doctype included */
|
|
157
|
-
content(): Promise<string>;
|
|
158
|
-
/**
|
|
159
|
-
* Replaces the document with `html` and waits for `waitUntil` (default "load"). Scripts and styles in it run and apply;
|
|
160
|
-
* the page keeps its URL and origin (it is not a `data:` page).
|
|
161
|
-
* @example
|
|
162
|
-
* await page.setContent("<button>Go</button><script>document.title = 'x'</script>");
|
|
163
|
-
*/
|
|
164
|
-
setContent(html: string, options?: {
|
|
165
|
-
timeout?: number;
|
|
166
|
-
waitUntil?: LoadState;
|
|
167
|
-
}): Promise<void>;
|
|
168
|
-
/** The title of the document now */
|
|
169
|
-
title(): Promise<string>;
|
|
170
|
-
/**
|
|
171
|
-
* Runs `fn` in the page, with `arg` as its only argument, and returns the result (a promise is awaited). `fn` is a function,
|
|
172
|
-
* the source of one (`"async () => ..."`), or any other string, which is an expression (`"document.title"`; it takes no argument).
|
|
173
|
-
* Values come back as plain JavaScript: Date, Map, Set, RegExp, BigInt, NaN, undefined, nested objects and arrays;
|
|
174
|
-
* an element as an `ElementHandle`; what cannot be copied (a function, window, error, promise) as a `RemoteObject` with its `type`.
|
|
175
|
-
* The page's own error message is kept (`ScriptError`). A function written under tsx must not contain named inner functions
|
|
176
|
-
* (the transpiler adds a `__name` helper the page lacks); a string always works.
|
|
177
|
-
* @example
|
|
178
|
-
* const count = await page.evaluate((min) => document.querySelectorAll("li").length > min, 3);
|
|
179
|
-
*/
|
|
180
|
-
evaluate<R = unknown, A = unknown>(fn: PageFunction<[A], R>, arg?: A): Promise<R>;
|
|
181
|
-
/**
|
|
182
|
-
* Sets the size of the viewport (and, optionally, the device pixel ratio); `null` puts the browser's own size back.
|
|
183
|
-
* @example
|
|
184
|
-
* await page.setViewport({ width: 390, height: 844, devicePixelRatio: 3 });
|
|
185
|
-
*/
|
|
186
|
-
setViewport(viewport: Viewport | null): Promise<void>;
|
|
187
|
-
/** @internal Chrome: lays this page out like a phone from now on (`use.isMobile`), including the size it has now */
|
|
188
|
-
setMobileLayout(): Promise<void>;
|
|
189
|
-
/** Playwright's name for `setViewport` */
|
|
190
|
-
setViewportSize(size: Viewport): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* The size this page was last given (`setViewport`, `setViewportSize`, or the default from config `use.viewport` when the
|
|
193
|
-
* browser opened it), read at once; null before one is known, after `setViewport(null)` and when config turns the viewport off.
|
|
194
|
-
*/
|
|
195
|
-
viewportSize(): {
|
|
196
|
-
width: number;
|
|
197
|
-
height: number;
|
|
198
|
-
} | null;
|
|
199
|
-
/** Gives the page the size from config `use.viewport` (1280x720 by default); the browser does this when it opens a page */
|
|
200
|
-
applyDefaultViewport(): Promise<void>;
|
|
201
18
|
/**
|
|
202
19
|
* What the browser sets up on every page it opens: the default size, then everything that has to be listening
|
|
203
20
|
* before the page does anything (requests, dialogs, logs, downloads, file pickers). Safe to call again.
|
|
204
21
|
*/
|
|
205
22
|
startTracking(): Promise<void>;
|
|
206
|
-
/**
|
|
207
|
-
* Takes a screenshot and returns the image (also written to `options.path`).
|
|
208
|
-
* @example
|
|
209
|
-
* await page.screenshot({ path: "out/home.png", fullPage: true });
|
|
210
|
-
*/
|
|
211
|
-
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
212
|
-
/** @internal The runner gives each test its own evidence folder */
|
|
213
|
-
setEvidence(evidence: Evidence | undefined): void;
|
|
214
|
-
/** Waits `ms` milliseconds. Prefer waiting for something (an assertion, `waitForNetworkIdle`) when you can */
|
|
215
|
-
waitForTimeout(ms: number): Promise<void>;
|
|
216
|
-
/** Renders the page as a PDF and returns it (also written to `options.path`) */
|
|
217
|
-
pdf(options?: PdfOptions): Promise<Buffer>;
|
|
218
|
-
/** The browser context (cookies, storage) this page belongs to */
|
|
219
|
-
context(): BrowserContext;
|
|
220
|
-
/** Makes HTTP requests from the test with this page's cookies; the same as `page.context().request` */
|
|
221
|
-
get request(): APIRequestContext;
|
|
222
|
-
/** @internal Called when the page is opened in a context */
|
|
223
|
-
setContext(context: BrowserContext): void;
|
|
224
|
-
/** @internal Marks the page closed after its tab is gone (its context was removed) and releases what it registered */
|
|
225
|
-
detach(): Promise<void>;
|
|
226
|
-
/**
|
|
227
|
-
* Changes the `use` options that can change while the browser runs for this page only: locale, timezone, user
|
|
228
|
-
* agent, geolocation, offline, orientation, screen, hasTouch, javaScriptEnabled. It wins over what the page's
|
|
229
|
-
* context says; `null` puts the real (or the context's) value back. Same options as `test.use()`, applied now.
|
|
230
|
-
* @example
|
|
231
|
-
* await page.use({ locale: "nl-NL", offline: true });
|
|
232
|
-
*/
|
|
233
|
-
use(options: RuntimeUseOptions): Promise<void>;
|
|
234
|
-
/**
|
|
235
|
-
* Grants a browser permission ("geolocation", "notifications", "camera", …) to the origin this page is on,
|
|
236
|
-
* or to `options.origin`. A geolocation override only answers once this is granted.
|
|
237
|
-
*/
|
|
238
|
-
grantPermission(name: string, options?: {
|
|
239
|
-
origin?: string;
|
|
240
|
-
}): Promise<void>;
|
|
241
|
-
/** True once `close()` has run */
|
|
242
|
-
get closed(): boolean;
|
|
243
|
-
private assertOpen;
|
|
244
|
-
/**
|
|
245
|
-
* Closes the tab and releases everything the page registered. Later calls on the page throw "page closed".
|
|
246
|
-
* With `runBeforeUnload` the page's `beforeunload` handlers run first. Closing the browser's last tab may end the browser.
|
|
247
|
-
*/
|
|
248
|
-
close(options?: {
|
|
249
|
-
runBeforeUnload?: boolean;
|
|
250
|
-
}): Promise<void>;
|
|
251
|
-
/**
|
|
252
|
-
* Waits until the page's document reached `state` (default "load"): "domcontentloaded" and "load" follow the
|
|
253
|
-
* document, "networkidle" is "load" plus a quiet network (see `waitForNetworkIdle`). Resolves at once when it
|
|
254
|
-
* is already there. Call it once the navigation has started; a document that is still the old one counts.
|
|
255
|
-
* @example
|
|
256
|
-
* await page.locator("a[@id='next']").click();
|
|
257
|
-
* await page.waitForLoadState("domcontentloaded");
|
|
258
|
-
*/
|
|
259
|
-
waitForLoadState(state?: LoadState, options?: {
|
|
260
|
-
timeout?: number;
|
|
261
|
-
}): Promise<void>;
|
|
262
|
-
/**
|
|
263
|
-
* Starts following this page's requests now. Tracking only sees requests made after it started, so the
|
|
264
|
-
* browser calls this when it opens a page; without it, tracking starts on first use. Does nothing when
|
|
265
|
-
* config `network.track` is false.
|
|
266
|
-
*/
|
|
267
|
-
startNetworkTracking(): Promise<void>;
|
|
268
|
-
/**
|
|
269
|
-
* Waits until no request has been in flight for `idleTime` ms (default config `network.idleTime`, then 500).
|
|
270
|
-
* Long-lived requests (server-sent events, long polling) keep the page busy until `timeout`.
|
|
271
|
-
*/
|
|
272
|
-
waitForNetworkIdle(options?: {
|
|
273
|
-
idleTime?: number;
|
|
274
|
-
timeout?: number;
|
|
275
|
-
}): Promise<void>;
|
|
276
|
-
/**
|
|
277
|
-
* Listens for page events: `request`, `response`, `requestfailed` (network), `dialog` (a JavaScript dialog or
|
|
278
|
-
* `beforeunload` prompt opened; answer it with `dialog.accept()` / `dialog.dismiss()`), `console` (a `console.*` call)
|
|
279
|
-
* and `pageerror` (an uncaught exception). Starts what the event needs.
|
|
280
|
-
* A dialog nobody answers is dismissed automatically (a `beforeunload` prompt is accepted), so it cannot hang a test.
|
|
281
|
-
* @example
|
|
282
|
-
* page.on("dialog", (dialog) => dialog.accept());
|
|
283
|
-
*/
|
|
284
|
-
on<E extends PageEventName>(event: E, listener: (...args: PageEvents[E]) => void): this;
|
|
285
|
-
once<E extends PageEventName>(event: E, listener: (...args: PageEvents[E]) => void): this;
|
|
286
|
-
off<E extends PageEventName>(event: E, listener: (...args: PageEvents[E]) => void): this;
|
|
287
|
-
private trackInBackground;
|
|
288
|
-
/** Starts following downloads; the browser does this when it opens a page, `page.on("download")` and `waitForDownload` when needed */
|
|
289
|
-
startDownloadTracking(): Promise<void>;
|
|
290
|
-
/** Starts following file pickers; the browser does this when it opens a page, `page.on("filechooser")` and `waitForFileChooser` when needed */
|
|
291
|
-
startFileChooserTracking(): Promise<void>;
|
|
292
|
-
/**
|
|
293
|
-
* Resolves with the next download this page starts (when it starts, not when it ends: use `download.path()` for that).
|
|
294
|
-
* Call it before the download is triggered, or pass `trigger`, which runs once the wait is set up.
|
|
295
|
-
* @example
|
|
296
|
-
* const download = await page.waitForDownload({ trigger: () => link.click() });
|
|
297
|
-
* const file = await download.path();
|
|
298
|
-
*/
|
|
299
|
-
waitForDownload(options?: WaitOptions): Promise<Download>;
|
|
300
|
-
/**
|
|
301
|
-
* Resolves with the next file picker the page opens (a click on an `<input type=file>` or its label). Nothing shows
|
|
302
|
-
* on screen: answer it with `chooser.setFiles(...)`.
|
|
303
|
-
* @example
|
|
304
|
-
* const chooser = await page.waitForFileChooser({ trigger: () => page.locator("label[@for='avatar']").click() });
|
|
305
|
-
* await chooser.setFiles("./fixtures/avatar.png");
|
|
306
|
-
*/
|
|
307
|
-
waitForFileChooser(options?: WaitOptions): Promise<FileChooser>;
|
|
308
|
-
/**
|
|
309
|
-
* Playwright-style wait for one page event: `download`, `filechooser`, `request` or `response`. Same as the named
|
|
310
|
-
* `waitFor…` method, with an optional predicate (a function, or `predicate` in the options). Call it before the event
|
|
311
|
-
* is caused, or pass `trigger`, which runs once the wait is set up.
|
|
312
|
-
* @example
|
|
313
|
-
* const chooser = await page.waitForEvent("filechooser", { trigger: () => page.getByText("Upload file").click() });
|
|
314
|
-
* await chooser.setFiles("./myfile.pdf");
|
|
315
|
-
*/
|
|
316
|
-
waitForEvent<E extends WaitableEventName>(event: E, optionsOrPredicate?: ((item: PageEvents[E][0]) => boolean) | WaitForEventOptions<PageEvents[E][0]>): Promise<PageEvents[E][0]>;
|
|
317
|
-
/**
|
|
318
|
-
* Starts keeping response bodies, which is what makes `response.body()` possible: the browser only keeps a body
|
|
319
|
-
* when this ran before the request started. `page.on("response")` and `waitForResponse` call it; config
|
|
320
|
-
* `network.collectBodies` calls it when the browser opens the page.
|
|
321
|
-
*/
|
|
322
|
-
startBodyCollection(): Promise<void>;
|
|
323
|
-
/**
|
|
324
|
-
* Resolves with the next response of this page whose URL matches (a pattern, see `route`) or that the function
|
|
325
|
-
* accepts. Call it before the request is made, or pass `trigger`, which runs once the wait is set up.
|
|
326
|
-
* @example
|
|
327
|
-
* const response = await page.waitForResponse("**\/api/users", { trigger: () => button.click() });
|
|
328
|
-
* const users = await response.json();
|
|
329
|
-
*/
|
|
330
|
-
waitForResponse(match: NetworkMatch<Response>, options?: WaitOptions): Promise<Response>;
|
|
331
|
-
/** Like `waitForResponse`, for requests */
|
|
332
|
-
waitForRequest(match: NetworkMatch<NetworkRequest>, options?: WaitOptions): Promise<NetworkRequest>;
|
|
333
|
-
/**
|
|
334
|
-
* Resolves with the first `event` `matches` accepts. Listens before `trigger` runs, so what the trigger causes cannot
|
|
335
|
-
* be missed; a trigger that throws rejects the wait with its error. `onTimeout` builds the error for a wait that ran out.
|
|
336
|
-
*/
|
|
337
|
-
private waitForPageEvent;
|
|
338
|
-
/** Turns the browser's HTTP cache off (`true`) or back on for this page: every request then goes to the server */
|
|
339
|
-
setCacheDisabled(disabled: boolean): Promise<void>;
|
|
340
|
-
/**
|
|
341
|
-
* Sends requests whose URL matches to `handler`, which must answer with `route.fulfill()`, `route.continue()`,
|
|
342
|
-
* `route.abort()` or `route.fallback()` (await the answer: a handler that returns first lets the request continue).
|
|
343
|
-
* A string without `*` is an exact URL, with `*` / `**` a glob (`*` stops at `/`), a RegExp is tested on the URL.
|
|
344
|
-
* Routes added later are asked first. Errors a handler throws fail the request and, in the runner, the test.
|
|
345
|
-
* @example
|
|
346
|
-
* await page.route("**\/api/users", (route) => route.fulfill({ json: [{ id: 1 }] }));
|
|
347
|
-
* await page.route(/\.(png|jpg)$/, (route) => route.abort());
|
|
348
|
-
*/
|
|
349
|
-
route(url: UrlPattern, handler: RouteHandler): Promise<void>;
|
|
350
|
-
/** Removes the routes for `url` (only the one with `handler`, when given) */
|
|
351
|
-
unroute(url: UrlPattern, handler?: RouteHandler): Promise<void>;
|
|
352
|
-
unrouteAll(): Promise<void>;
|
|
353
|
-
/** Errors thrown by route handlers so far */
|
|
354
|
-
routeErrors(): readonly Error[];
|
|
355
|
-
/**
|
|
356
|
-
* Starts collecting the page's console output and uncaught exceptions. The browser does this when it opens a page so
|
|
357
|
-
* early output is kept; `page.on("console" | "pageerror")` starts it when needed.
|
|
358
|
-
*/
|
|
359
|
-
startLogging(): Promise<void>;
|
|
360
|
-
/** The newest console and error entries of this page (empty until logging started), oldest first */
|
|
361
|
-
getLogs(): readonly LogRecord[];
|
|
362
|
-
/** Uncaught exceptions of the page since logging started or `clearLogs()` */
|
|
363
|
-
pageErrors(): readonly PageError[];
|
|
364
|
-
/** How many entries fell out of the page's log buffer */
|
|
365
|
-
get logsDropped(): number;
|
|
366
|
-
clearLogs(): void;
|
|
367
|
-
/** Resolves once everything the page logged before the call has arrived: events and replies share one ordered connection */
|
|
368
|
-
syncLogs(): Promise<void>;
|
|
369
|
-
/** Tells the runner not to fail this test on uncaught page exceptions (config `logs.failOnPageError`) */
|
|
370
|
-
allowPageErrors(): void;
|
|
371
|
-
get pageErrorsAllowed(): boolean;
|
|
372
|
-
/** Starts watching for dialogs; the browser does this when it opens a page, `page.on("dialog")` when needed */
|
|
373
|
-
startDialogHandling(): Promise<void>;
|
|
374
23
|
}
|