testsurfer 0.1.2 → 0.3.0
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 +52 -149
- package/dist/browser.d.ts +135 -1
- package/dist/browser.js +378 -2
- package/dist/browser.js.map +1 -1
- package/dist/cli.d.ts +16 -0
- package/dist/cli.js +140 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +12 -2
- package/dist/client.js +73 -4
- package/dist/client.js.map +1 -1
- package/dist/diff.d.ts +19 -0
- package/dist/diff.js +116 -0
- package/dist/diff.js.map +1 -0
- package/dist/events.d.ts +386 -0
- package/dist/events.js +1035 -0
- package/dist/events.js.map +1 -0
- package/dist/expect.d.ts +135 -26
- package/dist/expect.js +634 -130
- package/dist/expect.js.map +1 -1
- package/dist/frame.d.ts +88 -0
- package/dist/frame.js +194 -0
- package/dist/frame.js.map +1 -0
- package/dist/global.d.ts +12 -0
- package/dist/global.js +136 -0
- package/dist/global.js.map +1 -0
- package/dist/hooks.d.ts +28 -0
- package/dist/hooks.js +48 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +22 -3
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/injected.d.ts +15 -0
- package/dist/injected.js +2025 -0
- package/dist/injected.js.map +1 -0
- package/dist/locator.d.ts +374 -86
- package/dist/locator.js +845 -244
- package/dist/locator.js.map +1 -1
- package/dist/media.d.ts +15 -0
- package/dist/media.js +83 -0
- package/dist/media.js.map +1 -0
- package/dist/net.d.ts +110 -0
- package/dist/net.js +498 -0
- package/dist/net.js.map +1 -0
- package/dist/page.d.ts +448 -5
- package/dist/page.js +1187 -31
- package/dist/page.js.map +1 -1
- package/dist/png.d.ts +28 -0
- package/dist/png.js +197 -0
- package/dist/png.js.map +1 -0
- package/dist/pwconfig.d.ts +66 -0
- package/dist/pwconfig.js +77 -0
- package/dist/pwconfig.js.map +1 -0
- package/dist/register.d.ts +6 -0
- package/dist/register.js +9 -0
- package/dist/register.js.map +1 -0
- package/dist/request.d.ts +29 -0
- package/dist/request.js +75 -0
- package/dist/request.js.map +1 -0
- package/dist/runner.d.ts +99 -15
- package/dist/runner.js +354 -58
- package/dist/runner.js.map +1 -1
- package/dist/screenshot.d.ts +35 -0
- package/dist/screenshot.js +171 -0
- package/dist/screenshot.js.map +1 -0
- package/dist/selector.d.ts +55 -0
- package/dist/selector.js +208 -0
- package/dist/selector.js.map +1 -0
- package/dist/selectors.d.ts +13 -0
- package/dist/selectors.js +16 -0
- package/dist/selectors.js.map +1 -0
- package/dist/serialize.d.ts +17 -0
- package/dist/serialize.js +149 -0
- package/dist/serialize.js.map +1 -0
- package/dist/shim.d.ts +15 -0
- package/dist/shim.js +211 -0
- package/dist/shim.js.map +1 -0
- package/dist/testinfo.d.ts +62 -0
- package/dist/testinfo.js +23 -0
- package/dist/testinfo.js.map +1 -0
- package/dist/values.d.ts +67 -0
- package/dist/values.js +293 -0
- package/dist/values.js.map +1 -0
- package/package.json +10 -3
- package/skills/testsurfer/SKILL.md +55 -0
package/dist/page.d.ts
CHANGED
|
@@ -4,8 +4,13 @@
|
|
|
4
4
|
* the page caches the latest one and every mutation uses it.
|
|
5
5
|
*/
|
|
6
6
|
import type { WireClient } from './client.ts';
|
|
7
|
+
import type { BrowserContext } from './browser.ts';
|
|
7
8
|
import { type Snapshot } from './tree.ts';
|
|
8
|
-
import { Locator, type ByRoleOptions, type ByTextOptions } from './locator.ts';
|
|
9
|
+
import { ElementHandle, FrameLocator, JSHandle, Locator, type BoundingBox, type ByRoleOptions, type ByTextOptions, type ClickOptions, type InputFile, type LocatorOptions, type SelectOptionValue } from './locator.ts';
|
|
10
|
+
import { APIRequestContext } from './request.ts';
|
|
11
|
+
import { Frame } from './frame.ts';
|
|
12
|
+
import { type MediaOptions } from './media.ts';
|
|
13
|
+
import { ConsoleMessage, type Dialog, PageEvents, Request, Response, type RouteHandler, type UrlMatcher } from './events.ts';
|
|
9
14
|
export interface Timeouts {
|
|
10
15
|
/** Budget for actions (click, fill, ...) including auto-waiting. */
|
|
11
16
|
action: number;
|
|
@@ -84,7 +89,157 @@ export declare class Page {
|
|
|
84
89
|
readonly actDeltas: boolean;
|
|
85
90
|
readonly navInPlace: boolean;
|
|
86
91
|
readonly baseURL: string | undefined;
|
|
92
|
+
/** HTTP requests from the test process (not the browser). */
|
|
93
|
+
readonly request: APIRequestContext;
|
|
94
|
+
private testIdOption;
|
|
95
|
+
/** Attribute getByTestId matches: the `testIdAttribute` launch option, else selectors.setTestIdAttribute(), else `data-testid`. */
|
|
96
|
+
get testIdAttribute(): string;
|
|
97
|
+
set testIdAttribute(name: string);
|
|
98
|
+
/** Document-start scripts, replayed into the web view when it is created. */
|
|
99
|
+
private initScripts;
|
|
100
|
+
private shimInstalled;
|
|
101
|
+
private readonly events;
|
|
102
|
+
private ctx;
|
|
87
103
|
constructor(client: WireClient, sessionId: string, timeouts: Timeouts, inputMode?: InputMode, clickVia?: ClickVia, protocol?: ProtocolOptions, baseURL?: string);
|
|
104
|
+
/** The page that opened this one; undefined when not a popup. */
|
|
105
|
+
private openerPage;
|
|
106
|
+
private closedFlag;
|
|
107
|
+
/** The URL a popup was opened with, until waitForLoadState() sees it loaded. */
|
|
108
|
+
private popupURL;
|
|
109
|
+
/**
|
|
110
|
+
* @internal Take over a page vibesurfer opened as a popup of `opener`
|
|
111
|
+
* (`--popups`). Joins the network hub at once, so the popup's first
|
|
112
|
+
* request is reported to it.
|
|
113
|
+
*/
|
|
114
|
+
adoptPopup(pageId: string, url: string, opener: Page | null): PageEvents;
|
|
115
|
+
/** @internal The vibesurfer page id, once the page has one. */
|
|
116
|
+
wireId(): string | null;
|
|
117
|
+
/** The page that opened this one (window.open, target=_blank), or null. */
|
|
118
|
+
opener(): Promise<Page | null>;
|
|
119
|
+
isClosed(): boolean;
|
|
120
|
+
/** @internal The page closed itself (window.close()); vibesurfer already released it. */
|
|
121
|
+
closedByPage(): void;
|
|
122
|
+
private markClosed;
|
|
123
|
+
/** @internal Report a popup this page opened. */
|
|
124
|
+
emitPopup(popup: Page): void;
|
|
125
|
+
/**
|
|
126
|
+
* @internal A dialog this page opened. Listeners on the page (or its
|
|
127
|
+
* context) decide; with none it is dismissed, as in Playwright.
|
|
128
|
+
*/
|
|
129
|
+
handleDialog(d: Dialog, contextListens: boolean): void;
|
|
130
|
+
/** @internal Set by the context that created this page. */
|
|
131
|
+
bindContext(ctx: BrowserContext): void;
|
|
132
|
+
/** The context this page belongs to. */
|
|
133
|
+
context(): BrowserContext;
|
|
134
|
+
private addInitSource;
|
|
135
|
+
private ensureShim;
|
|
136
|
+
/**
|
|
137
|
+
* Run a script at document start in every later document of this
|
|
138
|
+
* page, before the page's own scripts (Playwright's addInitScript).
|
|
139
|
+
* A function is called with `arg`. The current document is not
|
|
140
|
+
* touched.
|
|
141
|
+
*/
|
|
142
|
+
addInitScript(script: string | ((arg: never) => unknown) | {
|
|
143
|
+
path?: string;
|
|
144
|
+
content?: string;
|
|
145
|
+
}, arg?: unknown): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Emulate media features: matchMedia and the page's @media rules
|
|
148
|
+
* follow (see src/media.ts). null resets a feature. Applies to this
|
|
149
|
+
* document and later ones.
|
|
150
|
+
*/
|
|
151
|
+
emulateMedia(options?: MediaOptions): Promise<void>;
|
|
152
|
+
private media;
|
|
153
|
+
/**
|
|
154
|
+
* Add a <script> (from `url`, a file at `path`, or `content`) and
|
|
155
|
+
* wait for it to load. Returns its element.
|
|
156
|
+
*/
|
|
157
|
+
addScriptTag(options: {
|
|
158
|
+
url?: string;
|
|
159
|
+
path?: string;
|
|
160
|
+
content?: string;
|
|
161
|
+
type?: string;
|
|
162
|
+
}): Promise<ElementHandle>;
|
|
163
|
+
/** Add a <link rel=stylesheet> (from `url`) or a <style> (from `path` or `content`) and wait for it. */
|
|
164
|
+
addStyleTag(options: {
|
|
165
|
+
url?: string;
|
|
166
|
+
path?: string;
|
|
167
|
+
content?: string;
|
|
168
|
+
}): Promise<ElementHandle>;
|
|
169
|
+
/**
|
|
170
|
+
* Intercept fetch and XHR requests whose URL matches. The handler
|
|
171
|
+
* gets a Route to fulfill, continue, abort, fall back or fetch.
|
|
172
|
+
* Navigations, images, scripts and stylesheets are not intercepted.
|
|
173
|
+
*/
|
|
174
|
+
route(url: UrlMatcher, handler: RouteHandler, options?: {
|
|
175
|
+
times?: number;
|
|
176
|
+
}): Promise<void>;
|
|
177
|
+
/** Remove routes for `url` (only `handler`'s, when given). */
|
|
178
|
+
unroute(url: UrlMatcher, handler?: RouteHandler): Promise<void>;
|
|
179
|
+
unrouteAll(): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* Listen for `console`, `pageerror`, `request`, `response`,
|
|
182
|
+
* `requestfinished` or `requestfailed`. Requests and responses are
|
|
183
|
+
* fetch and XHR only.
|
|
184
|
+
*/
|
|
185
|
+
on(event: 'console', listener: (msg: ConsoleMessage) => void): this;
|
|
186
|
+
on(event: 'pageerror', listener: (error: Error) => void): this;
|
|
187
|
+
on(event: 'request' | 'requestfinished' | 'requestfailed', listener: (request: Request) => void): this;
|
|
188
|
+
on(event: 'response', listener: (response: Response) => void): this;
|
|
189
|
+
once(event: string, listener: (arg: never) => void): this;
|
|
190
|
+
off(event: string, listener: (arg: never) => void): this;
|
|
191
|
+
removeListener(event: string, listener: (arg: never) => void): this;
|
|
192
|
+
/** The next `event` that `predicate` accepts. */
|
|
193
|
+
waitForEvent<T = unknown>(event: string, optionsOrPredicate?: ((arg: T) => boolean | Promise<boolean>) | {
|
|
194
|
+
predicate?: (arg: T) => boolean | Promise<boolean>;
|
|
195
|
+
timeout?: number;
|
|
196
|
+
}): Promise<T>;
|
|
197
|
+
/** The next fetch/XHR request matching a URL pattern or predicate. */
|
|
198
|
+
waitForRequest(match: UrlMatcher | ((request: Request) => boolean | Promise<boolean>), options?: {
|
|
199
|
+
timeout?: number;
|
|
200
|
+
}): Promise<Request>;
|
|
201
|
+
/** The next fetch/XHR response matching a URL pattern or predicate. */
|
|
202
|
+
waitForResponse(match: UrlMatcher | ((response: Response) => boolean | Promise<boolean>), options?: {
|
|
203
|
+
timeout?: number;
|
|
204
|
+
}): Promise<Response>;
|
|
205
|
+
waitForTimeout(ms: number): Promise<void>;
|
|
206
|
+
/** Poll until the URL matches. */
|
|
207
|
+
waitForURL(url: UrlMatcher, options?: {
|
|
208
|
+
timeout?: number;
|
|
209
|
+
}): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Resolve when the page has loaded a new document (and, with `url`,
|
|
212
|
+
* one whose URL matches). Start it before the action that navigates:
|
|
213
|
+
* `await Promise.all([page.waitForNavigation(), link.click()])`.
|
|
214
|
+
*/
|
|
215
|
+
waitForNavigation(options?: {
|
|
216
|
+
url?: UrlMatcher;
|
|
217
|
+
timeout?: number;
|
|
218
|
+
waitUntil?: string;
|
|
219
|
+
}): Promise<null>;
|
|
220
|
+
/**
|
|
221
|
+
* goto() already waits for the load. A popup loads on its own, so
|
|
222
|
+
* for one this waits until its document is there and loaded.
|
|
223
|
+
*/
|
|
224
|
+
waitForLoadState(state?: 'load' | 'domcontentloaded' | 'networkidle', options?: {
|
|
225
|
+
timeout?: number;
|
|
226
|
+
}): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Replace the document with `html`; its scripts run. On an http(s)
|
|
229
|
+
* page the document is rewritten in place, so it keeps that origin
|
|
230
|
+
* and relative URLs resolve against it. Otherwise the page loads the
|
|
231
|
+
* HTML as a data: URL (an opaque origin, no storage): WebKit drops
|
|
232
|
+
* native clicks on a rewritten about:blank.
|
|
233
|
+
*/
|
|
234
|
+
setContent(html: string): Promise<void>;
|
|
235
|
+
/** The document's HTML, without the ref markers vibesurfer adds. */
|
|
236
|
+
content(): Promise<string>;
|
|
237
|
+
/** Load the current URL again. */
|
|
238
|
+
reload(): Promise<Response | null>;
|
|
239
|
+
/** History back; resolves once the URL changed (or immediately when there is no history). */
|
|
240
|
+
goBack(): Promise<void>;
|
|
241
|
+
goForward(): Promise<void>;
|
|
242
|
+
private historyMove;
|
|
88
243
|
/**
|
|
89
244
|
* Fold a 0.2 mutation response body (the ViewForm the daemon emitted
|
|
90
245
|
* while advancing its baseline) into the snapshot. Empty body means
|
|
@@ -94,12 +249,29 @@ export declare class Page {
|
|
|
94
249
|
*/
|
|
95
250
|
private applyMutationBody;
|
|
96
251
|
private get id();
|
|
252
|
+
/**
|
|
253
|
+
* A new page starts at about:blank, as in Playwright: the first call
|
|
254
|
+
* that needs a document opens one (with the init scripts installed).
|
|
255
|
+
*/
|
|
256
|
+
private ensureOpen;
|
|
97
257
|
/**
|
|
98
258
|
* Navigate to a URL, relative to the baseURL launch option when set.
|
|
99
259
|
* Navigates in place on protocol-v1 daemons; older ones close the
|
|
100
260
|
* page and open a new one.
|
|
101
261
|
*/
|
|
102
|
-
goto(target: string
|
|
262
|
+
goto(target: string, _options?: {
|
|
263
|
+
waitUntil?: string;
|
|
264
|
+
timeout?: number;
|
|
265
|
+
referer?: string;
|
|
266
|
+
}): Promise<Response | null>;
|
|
267
|
+
/**
|
|
268
|
+
* The main document's response after a navigation (vibesurfer 0.2.16+
|
|
269
|
+
* `vs_inspect response`), or null for data:, about: and file: URLs or
|
|
270
|
+
* on older daemons.
|
|
271
|
+
*/
|
|
272
|
+
private mainResponse;
|
|
273
|
+
/** `html`: load that document under the URL instead of fetching it (a routed document). */
|
|
274
|
+
private navigate;
|
|
103
275
|
/**
|
|
104
276
|
* Refresh the snapshot from the daemon and return it. Sends a plain
|
|
105
277
|
* (delta) view when our snapshot matches the daemon's baseline and a
|
|
@@ -133,6 +305,13 @@ export declare class Page {
|
|
|
133
305
|
* the caller can re-resolve and retry.
|
|
134
306
|
*/
|
|
135
307
|
act(ref: number, op: string, value?: string, extraFlags?: Record<string, string>): Promise<void>;
|
|
308
|
+
/**
|
|
309
|
+
* The action made the page close itself (a popup's "Close" button):
|
|
310
|
+
* vibesurfer released the page under the action, which then finds
|
|
311
|
+
* nothing. The action did its work; the close event follows on the
|
|
312
|
+
* event stream.
|
|
313
|
+
*/
|
|
314
|
+
private closedByItself;
|
|
136
315
|
/**
|
|
137
316
|
* Trusted native click at viewport coordinates via vs_click_at. The
|
|
138
317
|
* cursor op leaves the daemon's delta baseline and last token
|
|
@@ -168,9 +347,233 @@ export declare class Page {
|
|
|
168
347
|
* arguments. Runs through vs_inspect eval, which reads the page
|
|
169
348
|
* without mutating the daemon's state token.
|
|
170
349
|
*/
|
|
171
|
-
evaluate<T = unknown>(
|
|
350
|
+
evaluate<T = unknown, A = unknown>(fn: string | ((arg: A) => unknown), arg?: A): Promise<T>;
|
|
351
|
+
/** Raw evaluate through vs_inspect: JSON in, JSON out, no promise handling. */
|
|
352
|
+
private rawEval;
|
|
353
|
+
/**
|
|
354
|
+
* Run `body` (an expression that may use the engine as `E`) in the
|
|
355
|
+
* page, or in the subframe with URL `frame`. Installs the engine on
|
|
356
|
+
* first use in each document, waits out promises, and turns page
|
|
357
|
+
* exceptions into thrown Errors.
|
|
358
|
+
*/
|
|
359
|
+
engineCall(body: string, frame?: string | null): Promise<unknown>;
|
|
360
|
+
/** One locator-engine request (see src/injected.ts). `fn` is a function source passed alongside. */
|
|
361
|
+
engineRun<T>(req: Record<string, unknown>, fn?: string): Promise<T>;
|
|
362
|
+
/**
|
|
363
|
+
* engineRun in `frame`. A chain that crosses into a cross-origin
|
|
364
|
+
* frame stops there (XOFrame); the rest runs inside that frame, and
|
|
365
|
+
* a point it returns moves by where the frame sits in the page.
|
|
366
|
+
*/
|
|
367
|
+
private engineRunIn;
|
|
368
|
+
/** @internal page.evaluate() inside a cross-origin subframe, addressed by URL. */
|
|
369
|
+
evaluateInFrame<T = unknown, A = unknown>(frame: string, fn: string | ((arg: A) => unknown), arg?: A): Promise<T>;
|
|
370
|
+
/** Log lines from the last locator-handler run that blocked a wait. */
|
|
371
|
+
handlerLog: string[];
|
|
372
|
+
private locatorHandlers;
|
|
373
|
+
private handlingLocators;
|
|
374
|
+
/**
|
|
375
|
+
* Run `handler` whenever `locator` becomes visible while an action or
|
|
376
|
+
* assertion is waiting (a cookie banner, a newsletter dialog). By
|
|
377
|
+
* default the wait resumes once the locator is hidden again.
|
|
378
|
+
*/
|
|
379
|
+
addLocatorHandler(locator: Locator, handler: (locator: Locator) => unknown, options?: {
|
|
380
|
+
times?: number;
|
|
381
|
+
noWaitAfter?: boolean;
|
|
382
|
+
}): Promise<void>;
|
|
383
|
+
removeLocatorHandler(locator: Locator): Promise<void>;
|
|
384
|
+
/**
|
|
385
|
+
* @internal Run the handlers whose locator is visible now. Called on
|
|
386
|
+
* each action and assertion retry. Returns false while a handled
|
|
387
|
+
* locator has not gone away yet: the caller keeps waiting, as
|
|
388
|
+
* Playwright does, until it hides or the caller's time runs out.
|
|
389
|
+
*/
|
|
390
|
+
runLocatorHandlers(deadline?: number): Promise<boolean>;
|
|
391
|
+
/** Poll `fn(arg)` in the page until it returns a truthy value, and return that value. */
|
|
392
|
+
waitForFunction<T = unknown, A = unknown>(fn: string | ((arg: A) => unknown), arg?: A, options?: {
|
|
393
|
+
timeout?: number;
|
|
394
|
+
polling?: number | 'raf';
|
|
395
|
+
}): Promise<JSHandle & {
|
|
396
|
+
jsonValue(): Promise<T>;
|
|
397
|
+
}>;
|
|
398
|
+
/** `fn(element, arg)` on the first element matching `selector`; throws when there is none. */
|
|
399
|
+
$eval<R, A = unknown>(selector: string, fn: string | ((el: any, arg: A) => R | Promise<R>), arg?: A): Promise<R>;
|
|
400
|
+
/** `fn(elements, arg)` with every element matching `selector`. */
|
|
401
|
+
$$eval<R, A = unknown>(selector: string, fn: string | ((els: any[], arg: A) => R | Promise<R>), arg?: A): Promise<R>;
|
|
402
|
+
/** The first element matching `selector`, or null. */
|
|
403
|
+
$(selector: string): Promise<ElementHandle | null>;
|
|
404
|
+
/** Every element matching `selector`. */
|
|
405
|
+
$$(selector: string): Promise<ElementHandle[]>;
|
|
406
|
+
private main;
|
|
407
|
+
/** The page's top frame. */
|
|
408
|
+
mainFrame(): Frame;
|
|
409
|
+
private frameCache;
|
|
410
|
+
private lastFrameCount;
|
|
411
|
+
/** Refreshes run one after another, so an older listing never overwrites a newer one. */
|
|
412
|
+
private frameChain;
|
|
413
|
+
/**
|
|
414
|
+
* The main frame, then every iframe, depth first, as of the last
|
|
415
|
+
* navigation or refreshFrames() call (Playwright's frames() is
|
|
416
|
+
* synchronous; testsurfer reads the frame tree after each load).
|
|
417
|
+
*/
|
|
418
|
+
frames(): Frame[];
|
|
419
|
+
/** Re-read the frame tree, for iframes added after the page loaded. */
|
|
420
|
+
refreshFrames(): Promise<Frame[]>;
|
|
421
|
+
private readFrames;
|
|
422
|
+
/** A frame by name, or by URL (string, RegExp or predicate). */
|
|
423
|
+
frame(match: string | {
|
|
424
|
+
name?: string;
|
|
425
|
+
url?: string | RegExp | ((u: URL) => boolean);
|
|
426
|
+
}): Frame | null;
|
|
427
|
+
/**
|
|
428
|
+
* Make `fn` callable from the page as `window[name](...args)`; the
|
|
429
|
+
* call returns a promise of fn's result. Arguments and results cross
|
|
430
|
+
* as JSON. Covers this document and every later one.
|
|
431
|
+
*/
|
|
432
|
+
exposeFunction(name: string, fn: (...args: any[]) => unknown): Promise<void>;
|
|
433
|
+
/** Like exposeFunction, with `{ page, context, frame }` as the first argument. */
|
|
434
|
+
exposeBinding(name: string, fn: (source: {
|
|
435
|
+
page: Page;
|
|
436
|
+
context: BrowserContext | null;
|
|
437
|
+
frame: Frame;
|
|
438
|
+
}, ...args: any[]) => unknown): Promise<void>;
|
|
439
|
+
private extraHeaders;
|
|
440
|
+
/** @internal Re-apply routing after the context's network settings changed. */
|
|
441
|
+
refreshNetwork(): Promise<void>;
|
|
442
|
+
/**
|
|
443
|
+
* Headers added to every request this page makes. In proxy mode they
|
|
444
|
+
* reach every http request; otherwise fetch and XHR only.
|
|
445
|
+
*/
|
|
446
|
+
setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
|
|
447
|
+
/** Like evaluate(), but keeps the result in the page and returns a handle to it. */
|
|
448
|
+
evaluateHandle<A = unknown>(fn: string | ((arg: A) => unknown), arg?: A): Promise<JSHandle>;
|
|
449
|
+
/** @internal Evaluate `expr` (may be a promise) and hand back a handle to its value. */
|
|
450
|
+
adoptResult(expr: string): Promise<JSHandle>;
|
|
451
|
+
/** Wait for `selector` to reach a state (visible by default); returns the element as a locator. */
|
|
452
|
+
waitForSelector(selector: string, options?: {
|
|
453
|
+
state?: 'attached' | 'detached' | 'visible' | 'hidden';
|
|
454
|
+
timeout?: number;
|
|
455
|
+
}): Promise<ElementHandle | null>;
|
|
456
|
+
private pick;
|
|
457
|
+
click(selector: string, options?: ClickOptions): Promise<void>;
|
|
458
|
+
dblclick(selector: string, options?: ClickOptions): Promise<void>;
|
|
459
|
+
tap(selector: string, options?: ClickOptions): Promise<void>;
|
|
460
|
+
hover(selector: string, options?: {
|
|
461
|
+
timeout?: number;
|
|
462
|
+
force?: boolean;
|
|
463
|
+
}): Promise<void>;
|
|
464
|
+
focus(selector: string, options?: {
|
|
465
|
+
timeout?: number;
|
|
466
|
+
}): Promise<void>;
|
|
467
|
+
fill(selector: string, value: string, options?: {
|
|
468
|
+
timeout?: number;
|
|
469
|
+
force?: boolean;
|
|
470
|
+
}): Promise<void>;
|
|
471
|
+
type(selector: string, text: string, options?: {
|
|
472
|
+
timeout?: number;
|
|
473
|
+
}): Promise<void>;
|
|
474
|
+
press(selector: string, key: string, options?: {
|
|
475
|
+
timeout?: number;
|
|
476
|
+
}): Promise<void>;
|
|
477
|
+
check(selector: string, options?: ClickOptions): Promise<void>;
|
|
478
|
+
uncheck(selector: string, options?: ClickOptions): Promise<void>;
|
|
479
|
+
setChecked(selector: string, checked: boolean, options?: ClickOptions): Promise<void>;
|
|
480
|
+
selectOption(selector: string, values: SelectOptionValue | SelectOptionValue[] | null, options?: {
|
|
481
|
+
timeout?: number;
|
|
482
|
+
}): Promise<string[]>;
|
|
483
|
+
setInputFiles(selector: string, files: InputFile | InputFile[], options?: {
|
|
484
|
+
timeout?: number;
|
|
485
|
+
}): Promise<void>;
|
|
486
|
+
dispatchEvent(selector: string, type: string, eventInit?: Record<string, unknown>, options?: {
|
|
487
|
+
timeout?: number;
|
|
488
|
+
}): Promise<void>;
|
|
489
|
+
textContent(selector: string, options?: {
|
|
490
|
+
timeout?: number;
|
|
491
|
+
}): Promise<string>;
|
|
492
|
+
innerText(selector: string, options?: {
|
|
493
|
+
timeout?: number;
|
|
494
|
+
}): Promise<string>;
|
|
495
|
+
innerHTML(selector: string, options?: {
|
|
496
|
+
timeout?: number;
|
|
497
|
+
}): Promise<string>;
|
|
498
|
+
getAttribute(selector: string, name: string, options?: {
|
|
499
|
+
timeout?: number;
|
|
500
|
+
}): Promise<string | null>;
|
|
501
|
+
inputValue(selector: string, options?: {
|
|
502
|
+
timeout?: number;
|
|
503
|
+
}): Promise<string>;
|
|
504
|
+
isVisible(selector: string): Promise<boolean>;
|
|
505
|
+
isHidden(selector: string): Promise<boolean>;
|
|
506
|
+
isChecked(selector: string, options?: {
|
|
507
|
+
timeout?: number;
|
|
508
|
+
}): Promise<boolean>;
|
|
509
|
+
isDisabled(selector: string, options?: {
|
|
510
|
+
timeout?: number;
|
|
511
|
+
}): Promise<boolean>;
|
|
512
|
+
isEnabled(selector: string, options?: {
|
|
513
|
+
timeout?: number;
|
|
514
|
+
}): Promise<boolean>;
|
|
515
|
+
isEditable(selector: string, options?: {
|
|
516
|
+
timeout?: number;
|
|
517
|
+
}): Promise<boolean>;
|
|
518
|
+
/**
|
|
519
|
+
* Keyboard input to the focused element. press/down/up dispatch key
|
|
520
|
+
* events with the browser's default action (typing, Enter submits,
|
|
521
|
+
* Backspace deletes, Tab moves focus); type() sends trusted
|
|
522
|
+
* per-character input.
|
|
523
|
+
*/
|
|
524
|
+
readonly keyboard: {
|
|
525
|
+
press: (key: string, _options?: {
|
|
526
|
+
delay?: number;
|
|
527
|
+
}) => Promise<void>;
|
|
528
|
+
down: (key: string) => Promise<void>;
|
|
529
|
+
up: (key: string) => Promise<void>;
|
|
530
|
+
type: (text: string, _options?: {
|
|
531
|
+
delay?: number;
|
|
532
|
+
}) => Promise<void>;
|
|
533
|
+
insertText: (text: string) => Promise<void>;
|
|
534
|
+
};
|
|
535
|
+
private viewport;
|
|
536
|
+
private dpr;
|
|
537
|
+
/** @internal Size every new web view of this page gets. */
|
|
538
|
+
initialViewport(size: {
|
|
539
|
+
width: number;
|
|
540
|
+
height: number;
|
|
541
|
+
} | null, dpr: number): void;
|
|
542
|
+
/**
|
|
543
|
+
* @internal Take over a blank page the browser opened ahead of time
|
|
544
|
+
* (see Browser.newContext), already sized to `sized`. The first goto
|
|
545
|
+
* then navigates it in place instead of opening a web view.
|
|
546
|
+
*/
|
|
547
|
+
adoptBlank(pageId: string, token: string, sized: {
|
|
548
|
+
width: number;
|
|
549
|
+
height: number;
|
|
550
|
+
dpr: number;
|
|
551
|
+
} | null): Promise<void>;
|
|
552
|
+
private applyViewport;
|
|
553
|
+
/** Resize the page (CSS px). */
|
|
554
|
+
setViewportSize(size: {
|
|
555
|
+
width: number;
|
|
556
|
+
height: number;
|
|
557
|
+
}): Promise<void>;
|
|
558
|
+
viewportSize(): {
|
|
559
|
+
width: number;
|
|
560
|
+
height: number;
|
|
561
|
+
} | null;
|
|
562
|
+
/** Viewport crop of the page around `box` (CSS px), as PNG bytes; written to `path` when given. */
|
|
563
|
+
screenshotClip(box: BoundingBox, path?: string): Promise<Buffer>;
|
|
172
564
|
/** The page's current URL. */
|
|
173
|
-
url()
|
|
565
|
+
/** The location every engine call reports; Playwright's page.url() is synchronous. */
|
|
566
|
+
private lastHref;
|
|
567
|
+
/** A service worker controlled the page as of the last engine call. */
|
|
568
|
+
private swControlled;
|
|
569
|
+
/** The page's URL as of the last call into the page (actions, reads and navigations all refresh it). */
|
|
570
|
+
url(): string;
|
|
571
|
+
/** Read location.href now. */
|
|
572
|
+
private currentURL;
|
|
573
|
+
private shownURL;
|
|
574
|
+
/** What goto() was asked for, and what the engine then reports. */
|
|
575
|
+
private navURL;
|
|
576
|
+
private rememberNav;
|
|
174
577
|
/**
|
|
175
578
|
* Save a PNG of the viewport (or the whole page with `fullPage`).
|
|
176
579
|
* Returns the file path; with `path`, the file is copied there.
|
|
@@ -178,12 +581,20 @@ export declare class Page {
|
|
|
178
581
|
screenshot(options?: {
|
|
179
582
|
path?: string;
|
|
180
583
|
fullPage?: boolean;
|
|
584
|
+
clip?: BoundingBox;
|
|
585
|
+
}): Promise<Buffer>;
|
|
586
|
+
/** PNG of the page, or of one element when `ref` is given. Returns the file path. */
|
|
587
|
+
capture(ref: number | null, options?: {
|
|
588
|
+
path?: string;
|
|
589
|
+
fullPage?: boolean;
|
|
181
590
|
}): Promise<string>;
|
|
182
591
|
/**
|
|
183
592
|
* Save this page's login state (cookies, local and session storage,
|
|
184
593
|
* IndexedDB) under `name`, encrypted at rest by the daemon. Load it
|
|
185
594
|
* in a later run with loadAuth(name) to skip the login flow.
|
|
186
595
|
*/
|
|
596
|
+
/** @internal Load an imported cookie blob into this page's jar (the session's). */
|
|
597
|
+
loadCookieBlob(name: string): Promise<void>;
|
|
187
598
|
saveAuth(name: string): Promise<void>;
|
|
188
599
|
/**
|
|
189
600
|
* Restore login state saved with saveAuth(name). Storage is per
|
|
@@ -200,24 +611,56 @@ export declare class Page {
|
|
|
200
611
|
* mode unless a call overrides it.
|
|
201
612
|
*/
|
|
202
613
|
readonly mouse: {
|
|
614
|
+
/**
|
|
615
|
+
* Move the pointer. While a button is down (mouse.down()), the move
|
|
616
|
+
* is only recorded: the press, the path and the release go out as
|
|
617
|
+
* one native drag at mouse.up(), so the page sees them in order.
|
|
618
|
+
*/
|
|
203
619
|
move: (x: number, y: number, options?: {
|
|
204
620
|
mode?: InputMode;
|
|
621
|
+
steps?: number;
|
|
205
622
|
}) => Promise<void>;
|
|
206
623
|
click: (x: number, y: number, options?: {
|
|
207
624
|
mode?: InputMode;
|
|
208
625
|
}) => Promise<void>;
|
|
626
|
+
down: () => Promise<void>;
|
|
627
|
+
up: (options?: {
|
|
628
|
+
mode?: InputMode;
|
|
629
|
+
}) => Promise<void>;
|
|
630
|
+
/**
|
|
631
|
+
* Scroll by (deltaX, deltaY) at the pointer: a wheel event goes to
|
|
632
|
+
* the element there and, unless the page cancels it, the nearest
|
|
633
|
+
* scrollable box scrolls. The event is dispatched in the page, so
|
|
634
|
+
* it is not trusted.
|
|
635
|
+
*/
|
|
636
|
+
wheel: (deltaX: number, deltaY: number) => Promise<void>;
|
|
209
637
|
/** Press at (x1, y1), move along a path, release at (x2, y2). Fires the HTML5 drag events too. */
|
|
210
638
|
drag: (x1: number, y1: number, x2: number, y2: number, options?: {
|
|
211
639
|
mode?: InputMode;
|
|
212
640
|
}) => Promise<void>;
|
|
213
641
|
};
|
|
642
|
+
/** Where mouse.move/click last put the pointer, and where mouse.down pressed. */
|
|
643
|
+
private pointer;
|
|
644
|
+
private pressedAt;
|
|
214
645
|
private cursorOp;
|
|
215
646
|
/** The whole page as template text (see toMatchAriaSnapshot). */
|
|
216
647
|
ariaSnapshot(): Promise<string>;
|
|
217
|
-
/** The document title
|
|
648
|
+
/** The document title. */
|
|
218
649
|
title(): Promise<string>;
|
|
219
650
|
getByRole(role: string, options?: ByRoleOptions): Locator;
|
|
220
651
|
getByText(text: string | RegExp, options?: ByTextOptions): Locator;
|
|
221
652
|
getByLabel(text: string | RegExp, options?: ByTextOptions): Locator;
|
|
653
|
+
/** Locators inside the iframe matching `selector` (same-origin frames, vibesurfer 0.2.15+). */
|
|
654
|
+
frameLocator(selector: string): FrameLocator;
|
|
655
|
+
/** Elements matching a CSS selector, mapped to their tree nodes. */
|
|
656
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
657
|
+
/** Exact match on the test-id attribute (`data-testid` by default). */
|
|
658
|
+
getByTestId(id: string | RegExp): Locator;
|
|
659
|
+
/** Fields by placeholder text (substring, case-insensitive; exact for whole-string). */
|
|
660
|
+
getByPlaceholder(text: string | RegExp, options?: ByTextOptions): Locator;
|
|
661
|
+
/** Images and areas by alt text. */
|
|
662
|
+
getByAltText(text: string | RegExp, options?: ByTextOptions): Locator;
|
|
663
|
+
/** Elements by their title attribute. */
|
|
664
|
+
getByTitle(text: string | RegExp, options?: ByTextOptions): Locator;
|
|
222
665
|
close(): Promise<void>;
|
|
223
666
|
}
|