@ohos-ports/vibium 26.5.31-beta.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/LICENSE +201 -0
- package/NOTICE +7 -0
- package/README.md +72 -0
- package/bin/cli.js +41 -0
- package/dist/bidi-bridge.js +639 -0
- package/dist/index.d.mts +1397 -0
- package/dist/index.d.ts +1397 -0
- package/dist/index.js +3395 -0
- package/dist/index.mjs +3334 -0
- package/dist/sync.d.mts +613 -0
- package/dist/sync.d.ts +613 -0
- package/dist/sync.js +1112 -0
- package/dist/sync.mjs +1069 -0
- package/dist/worker.js +3639 -0
- package/package.json +68 -0
- package/postinstall.js +35 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1397 @@
|
|
|
1
|
+
import * as node_stream from 'node:stream';
|
|
2
|
+
import { Writable, Readable } from 'stream';
|
|
3
|
+
|
|
4
|
+
interface VibiumProcessOptions {
|
|
5
|
+
headless?: boolean;
|
|
6
|
+
executablePath?: string;
|
|
7
|
+
connectURL?: string;
|
|
8
|
+
connectHeaders?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
declare class VibiumProcess {
|
|
11
|
+
private _process;
|
|
12
|
+
private _stopped;
|
|
13
|
+
private _preReadyLines;
|
|
14
|
+
private constructor();
|
|
15
|
+
/** The child process stdin stream (for sending commands). */
|
|
16
|
+
get stdin(): node_stream.Writable;
|
|
17
|
+
/** The child process stdout stream (for receiving responses/events). */
|
|
18
|
+
get stdout(): node_stream.Readable;
|
|
19
|
+
/** Lines received before the vibium:lifecycle.ready signal (buffered events). */
|
|
20
|
+
get preReadyLines(): string[];
|
|
21
|
+
static start(options?: VibiumProcessOptions): Promise<VibiumProcess>;
|
|
22
|
+
private _cleanupListeners;
|
|
23
|
+
stop(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface BiDiEvent {
|
|
27
|
+
method: string;
|
|
28
|
+
params: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type EventHandler = (event: BiDiEvent) => void;
|
|
32
|
+
declare class BiDiClient {
|
|
33
|
+
private stdin;
|
|
34
|
+
private rl;
|
|
35
|
+
private nextId;
|
|
36
|
+
private pendingCommands;
|
|
37
|
+
private eventHandlers;
|
|
38
|
+
private _closed;
|
|
39
|
+
private constructor();
|
|
40
|
+
/**
|
|
41
|
+
* Create a BiDiClient from stdin/stdout streams.
|
|
42
|
+
* Optionally replay pre-ready lines (events received before the ready signal).
|
|
43
|
+
*/
|
|
44
|
+
static fromStreams(stdin: Writable, stdout: Readable, preReadyLines?: string[]): BiDiClient;
|
|
45
|
+
private handleResponse;
|
|
46
|
+
private handleEvent;
|
|
47
|
+
onEvent(handler: EventHandler): void;
|
|
48
|
+
offEvent(handler: EventHandler): void;
|
|
49
|
+
send<T = unknown>(method: string, params?: Record<string, unknown>, timeout?: number): Promise<T>;
|
|
50
|
+
close(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare const customInspect$5: unique symbol;
|
|
54
|
+
interface BoundingBox {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}
|
|
60
|
+
interface ElementInfo {
|
|
61
|
+
tag: string;
|
|
62
|
+
text: string;
|
|
63
|
+
box: BoundingBox;
|
|
64
|
+
}
|
|
65
|
+
interface ActionOptions {
|
|
66
|
+
/** Timeout in milliseconds for actionability checks. Default: 30000 */
|
|
67
|
+
timeout?: number;
|
|
68
|
+
}
|
|
69
|
+
interface SelectorOptions {
|
|
70
|
+
role?: string;
|
|
71
|
+
text?: string;
|
|
72
|
+
label?: string;
|
|
73
|
+
placeholder?: string;
|
|
74
|
+
alt?: string;
|
|
75
|
+
title?: string;
|
|
76
|
+
testid?: string;
|
|
77
|
+
xpath?: string;
|
|
78
|
+
near?: string;
|
|
79
|
+
timeout?: number;
|
|
80
|
+
}
|
|
81
|
+
declare class Element {
|
|
82
|
+
private client;
|
|
83
|
+
private context;
|
|
84
|
+
private selector;
|
|
85
|
+
private _index?;
|
|
86
|
+
private _params;
|
|
87
|
+
readonly info: ElementInfo;
|
|
88
|
+
constructor(client: BiDiClient, context: string, selector: string, info: ElementInfo, index?: number, params?: Record<string, unknown>);
|
|
89
|
+
/** Build the common params sent to vibium: commands for element resolution. */
|
|
90
|
+
private commandParams;
|
|
91
|
+
/** Return params that can identify this element for use as a target (e.g. dragTo). */
|
|
92
|
+
toParams(): Record<string, unknown>;
|
|
93
|
+
/**
|
|
94
|
+
* Click the element.
|
|
95
|
+
* Waits for element to be visible, stable, receive events, and enabled.
|
|
96
|
+
*/
|
|
97
|
+
click(options?: ActionOptions): Promise<void>;
|
|
98
|
+
/** Double-click the element. */
|
|
99
|
+
dblclick(options?: ActionOptions): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Fill the element with text (clears existing content first).
|
|
102
|
+
* For inputs and textareas.
|
|
103
|
+
*/
|
|
104
|
+
fill(value: string, options?: ActionOptions): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Type text into the element (appends to existing content).
|
|
107
|
+
* Waits for element to be visible, stable, receive events, enabled, and editable.
|
|
108
|
+
*/
|
|
109
|
+
type(text: string, options?: ActionOptions): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Press a key while the element is focused.
|
|
112
|
+
* Supports key names ("Enter", "Tab") and combos ("Control+a").
|
|
113
|
+
*/
|
|
114
|
+
press(key: string, options?: ActionOptions): Promise<void>;
|
|
115
|
+
/** Clear the element's content (select all + delete). */
|
|
116
|
+
clear(options?: ActionOptions): Promise<void>;
|
|
117
|
+
/** Check a checkbox (no-op if already checked). */
|
|
118
|
+
check(options?: ActionOptions): Promise<void>;
|
|
119
|
+
/** Uncheck a checkbox (no-op if already unchecked). */
|
|
120
|
+
uncheck(options?: ActionOptions): Promise<void>;
|
|
121
|
+
/** Select an option in a <select> element by value. */
|
|
122
|
+
selectOption(value: string, options?: ActionOptions): Promise<void>;
|
|
123
|
+
/** Hover over the element (move mouse to center, no click). */
|
|
124
|
+
hover(options?: ActionOptions): Promise<void>;
|
|
125
|
+
/** Focus the element. */
|
|
126
|
+
focus(options?: ActionOptions): Promise<void>;
|
|
127
|
+
/** Drag this element to a target element. */
|
|
128
|
+
dragTo(target: Element, options?: ActionOptions): Promise<void>;
|
|
129
|
+
/** Tap the element (touch action). */
|
|
130
|
+
tap(options?: ActionOptions): Promise<void>;
|
|
131
|
+
/** Scroll the element into view. */
|
|
132
|
+
scrollIntoView(options?: ActionOptions): Promise<void>;
|
|
133
|
+
/** Dispatch a DOM event on the element. */
|
|
134
|
+
dispatchEvent(eventType: string, eventInit?: Record<string, unknown>, options?: ActionOptions): Promise<void>;
|
|
135
|
+
/** Set files on an <input type="file"> element. */
|
|
136
|
+
setFiles(files: string[], options?: ActionOptions): Promise<void>;
|
|
137
|
+
/** Get the element's textContent (trimmed). */
|
|
138
|
+
text(): Promise<string>;
|
|
139
|
+
/** Get the element's innerText (rendered text only). */
|
|
140
|
+
innerText(): Promise<string>;
|
|
141
|
+
/** Get the element's innerHTML. */
|
|
142
|
+
html(): Promise<string>;
|
|
143
|
+
/** Get the element's value (for inputs, textareas, selects). */
|
|
144
|
+
value(): Promise<string>;
|
|
145
|
+
/** Get an attribute value. Short name for getAttribute. */
|
|
146
|
+
attr(name: string): Promise<string | null>;
|
|
147
|
+
/** Get an attribute value. Alias for attr(). */
|
|
148
|
+
getAttribute(name: string): Promise<string | null>;
|
|
149
|
+
/** Get the element's bounding box. Short name for boundingBox. */
|
|
150
|
+
bounds(): Promise<BoundingBox>;
|
|
151
|
+
/** Get the element's bounding box. Alias for bounds(). */
|
|
152
|
+
boundingBox(): Promise<BoundingBox>;
|
|
153
|
+
/** Check if the element is visible (has dimensions, not display:none/visibility:hidden/opacity:0). */
|
|
154
|
+
isVisible(): Promise<boolean>;
|
|
155
|
+
/** Check if the element is hidden (inverse of isVisible). */
|
|
156
|
+
isHidden(): Promise<boolean>;
|
|
157
|
+
/** Check if the element is enabled (not disabled). */
|
|
158
|
+
isEnabled(): Promise<boolean>;
|
|
159
|
+
/** Check if the element is checked (for checkboxes/radios). */
|
|
160
|
+
isChecked(): Promise<boolean>;
|
|
161
|
+
/** Check if the element is editable (not disabled and not readonly). */
|
|
162
|
+
isEditable(): Promise<boolean>;
|
|
163
|
+
/** Get the element's computed ARIA role. */
|
|
164
|
+
role(): Promise<string>;
|
|
165
|
+
/** Get the element's accessible name (label). */
|
|
166
|
+
label(): Promise<string>;
|
|
167
|
+
/** Take a screenshot of just this element. Returns a PNG buffer. */
|
|
168
|
+
screenshot(): Promise<Buffer>;
|
|
169
|
+
/** Wait until the element reaches a state: "visible", "hidden", "attached", or "detached". */
|
|
170
|
+
waitUntil(state?: string, options?: {
|
|
171
|
+
timeout?: number;
|
|
172
|
+
}): Promise<void>;
|
|
173
|
+
/** Find a child element by CSS selector or semantic options. Scoped to this element. */
|
|
174
|
+
find(selector: string | SelectorOptions, options?: {
|
|
175
|
+
timeout?: number;
|
|
176
|
+
}): FluentElement;
|
|
177
|
+
/** Find all child elements by CSS selector or semantic options. Scoped to this element. */
|
|
178
|
+
findAll(selector: string | SelectorOptions, options?: {
|
|
179
|
+
timeout?: number;
|
|
180
|
+
}): Promise<Element[]>;
|
|
181
|
+
[customInspect$5](): string;
|
|
182
|
+
private getCenter;
|
|
183
|
+
}
|
|
184
|
+
/** A Promise<Element> that also exposes Element methods for chaining. */
|
|
185
|
+
type FluentElement = Promise<Element> & {
|
|
186
|
+
click(options?: ActionOptions): Promise<void>;
|
|
187
|
+
dblclick(options?: ActionOptions): Promise<void>;
|
|
188
|
+
fill(value: string, options?: ActionOptions): Promise<void>;
|
|
189
|
+
type(text: string, options?: ActionOptions): Promise<void>;
|
|
190
|
+
press(key: string, options?: ActionOptions): Promise<void>;
|
|
191
|
+
clear(options?: ActionOptions): Promise<void>;
|
|
192
|
+
check(options?: ActionOptions): Promise<void>;
|
|
193
|
+
uncheck(options?: ActionOptions): Promise<void>;
|
|
194
|
+
selectOption(value: string, options?: ActionOptions): Promise<void>;
|
|
195
|
+
hover(options?: ActionOptions): Promise<void>;
|
|
196
|
+
focus(options?: ActionOptions): Promise<void>;
|
|
197
|
+
dragTo(target: Element, options?: ActionOptions): Promise<void>;
|
|
198
|
+
tap(options?: ActionOptions): Promise<void>;
|
|
199
|
+
scrollIntoView(options?: ActionOptions): Promise<void>;
|
|
200
|
+
dispatchEvent(eventType: string, eventInit?: Record<string, unknown>, options?: ActionOptions): Promise<void>;
|
|
201
|
+
setFiles(files: string[], options?: ActionOptions): Promise<void>;
|
|
202
|
+
text(): Promise<string>;
|
|
203
|
+
innerText(): Promise<string>;
|
|
204
|
+
html(): Promise<string>;
|
|
205
|
+
value(): Promise<string>;
|
|
206
|
+
attr(name: string): Promise<string | null>;
|
|
207
|
+
getAttribute(name: string): Promise<string | null>;
|
|
208
|
+
bounds(): Promise<BoundingBox>;
|
|
209
|
+
boundingBox(): Promise<BoundingBox>;
|
|
210
|
+
isVisible(): Promise<boolean>;
|
|
211
|
+
isHidden(): Promise<boolean>;
|
|
212
|
+
isEnabled(): Promise<boolean>;
|
|
213
|
+
isChecked(): Promise<boolean>;
|
|
214
|
+
isEditable(): Promise<boolean>;
|
|
215
|
+
role(): Promise<string>;
|
|
216
|
+
label(): Promise<string>;
|
|
217
|
+
screenshot(): Promise<Buffer>;
|
|
218
|
+
waitUntil(state?: string, options?: {
|
|
219
|
+
timeout?: number;
|
|
220
|
+
}): Promise<void>;
|
|
221
|
+
find(selector: string | SelectorOptions, options?: {
|
|
222
|
+
timeout?: number;
|
|
223
|
+
}): FluentElement;
|
|
224
|
+
findAll(selector: string | SelectorOptions, options?: {
|
|
225
|
+
timeout?: number;
|
|
226
|
+
}): Promise<Element[]>;
|
|
227
|
+
};
|
|
228
|
+
declare function fluent(promise: Promise<Element>): FluentElement;
|
|
229
|
+
|
|
230
|
+
interface RecordingStartOptions {
|
|
231
|
+
name?: string;
|
|
232
|
+
screenshots?: boolean;
|
|
233
|
+
snapshots?: boolean;
|
|
234
|
+
sources?: boolean;
|
|
235
|
+
title?: string;
|
|
236
|
+
bidi?: boolean;
|
|
237
|
+
/** Screenshot format: 'jpeg' (default, faster/smaller) or 'png' (lossless). */
|
|
238
|
+
format?: 'jpeg' | 'png';
|
|
239
|
+
/** JPEG quality 0.0-1.0 (default 0.5). Ignored for PNG. */
|
|
240
|
+
quality?: number;
|
|
241
|
+
}
|
|
242
|
+
interface RecordingStopOptions {
|
|
243
|
+
path?: string;
|
|
244
|
+
}
|
|
245
|
+
declare class Recording {
|
|
246
|
+
private client;
|
|
247
|
+
private userContextId;
|
|
248
|
+
constructor(client: BiDiClient, userContextId: string);
|
|
249
|
+
/** Start recording. */
|
|
250
|
+
start(options?: RecordingStartOptions): Promise<void>;
|
|
251
|
+
/** Stop recording and return the recording zip as a Buffer. */
|
|
252
|
+
stop(options?: RecordingStopOptions): Promise<Buffer>;
|
|
253
|
+
/** Start a new recording chunk (resets event buffer, keeps resources). */
|
|
254
|
+
startChunk(options?: {
|
|
255
|
+
name?: string;
|
|
256
|
+
title?: string;
|
|
257
|
+
}): Promise<void>;
|
|
258
|
+
/** Stop the current chunk and return the recording zip as a Buffer. */
|
|
259
|
+
stopChunk(options?: RecordingStopOptions): Promise<Buffer>;
|
|
260
|
+
/** Start a named group of actions in the recording. */
|
|
261
|
+
startGroup(name: string, options?: {
|
|
262
|
+
location?: {
|
|
263
|
+
file: string;
|
|
264
|
+
line?: number;
|
|
265
|
+
column?: number;
|
|
266
|
+
};
|
|
267
|
+
}): Promise<void>;
|
|
268
|
+
/** End the current group. */
|
|
269
|
+
stopGroup(): Promise<void>;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
interface Cookie {
|
|
273
|
+
name: string;
|
|
274
|
+
value: string;
|
|
275
|
+
domain: string;
|
|
276
|
+
path: string;
|
|
277
|
+
size: number;
|
|
278
|
+
httpOnly: boolean;
|
|
279
|
+
secure: boolean;
|
|
280
|
+
sameSite: string;
|
|
281
|
+
expiry?: number;
|
|
282
|
+
}
|
|
283
|
+
interface SetCookieParam {
|
|
284
|
+
name: string;
|
|
285
|
+
value: string;
|
|
286
|
+
domain?: string;
|
|
287
|
+
url?: string;
|
|
288
|
+
path?: string;
|
|
289
|
+
httpOnly?: boolean;
|
|
290
|
+
secure?: boolean;
|
|
291
|
+
sameSite?: string;
|
|
292
|
+
expiry?: number;
|
|
293
|
+
}
|
|
294
|
+
interface OriginState {
|
|
295
|
+
origin: string;
|
|
296
|
+
localStorage: {
|
|
297
|
+
name: string;
|
|
298
|
+
value: string;
|
|
299
|
+
}[];
|
|
300
|
+
sessionStorage: {
|
|
301
|
+
name: string;
|
|
302
|
+
value: string;
|
|
303
|
+
}[];
|
|
304
|
+
}
|
|
305
|
+
interface StorageState {
|
|
306
|
+
cookies: Cookie[];
|
|
307
|
+
origins: OriginState[];
|
|
308
|
+
}
|
|
309
|
+
declare class BrowserContext {
|
|
310
|
+
private client;
|
|
311
|
+
private userContextId;
|
|
312
|
+
readonly recording: Recording;
|
|
313
|
+
constructor(client: BiDiClient, userContextId: string);
|
|
314
|
+
/** The user context ID for this browser context. */
|
|
315
|
+
get id(): string;
|
|
316
|
+
/** Create a new page (tab) in this context. */
|
|
317
|
+
newPage(): Promise<Page>;
|
|
318
|
+
/** Close this context and all its pages. */
|
|
319
|
+
close(): Promise<void>;
|
|
320
|
+
/** Get cookies for this context. Optionally filter by URLs. */
|
|
321
|
+
cookies(urls?: string[]): Promise<Cookie[]>;
|
|
322
|
+
/** Set cookies in this context. */
|
|
323
|
+
setCookies(cookies: SetCookieParam[]): Promise<void>;
|
|
324
|
+
/** Clear all cookies in this context. */
|
|
325
|
+
clearCookies(): Promise<void>;
|
|
326
|
+
/** Get the storage state (cookies + localStorage + sessionStorage). */
|
|
327
|
+
storage(): Promise<StorageState>;
|
|
328
|
+
/** Set the storage state (cookies + localStorage + sessionStorage). */
|
|
329
|
+
setStorage(state: StorageState): Promise<void>;
|
|
330
|
+
/** Clear all storage (cookies + localStorage + sessionStorage). */
|
|
331
|
+
clearStorage(): Promise<void>;
|
|
332
|
+
/** Add an init script that runs before page scripts in this context. */
|
|
333
|
+
addInitScript(script: string): Promise<string>;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Network request and response data classes.
|
|
338
|
+
* Wrap BiDi event data for onRequest/onResponse callbacks.
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
/** Wraps a BiDi network.beforeRequestSent event. */
|
|
342
|
+
declare class Request {
|
|
343
|
+
private data;
|
|
344
|
+
private client;
|
|
345
|
+
constructor(data: Record<string, unknown>, client?: BiDiClient);
|
|
346
|
+
/** The request URL. */
|
|
347
|
+
url(): string;
|
|
348
|
+
/** The HTTP method (GET, POST, etc.). */
|
|
349
|
+
method(): string;
|
|
350
|
+
/** Request headers as a simple key-value object. */
|
|
351
|
+
headers(): Record<string, string>;
|
|
352
|
+
/** The request ID (BiDi network request identifier). */
|
|
353
|
+
requestId(): string;
|
|
354
|
+
/** Request body / post data. Uses BiDi network.getData when a data collector is active. */
|
|
355
|
+
postData(): Promise<string | null>;
|
|
356
|
+
}
|
|
357
|
+
/** Wraps a BiDi network.responseCompleted event. */
|
|
358
|
+
declare class Response {
|
|
359
|
+
private data;
|
|
360
|
+
private client;
|
|
361
|
+
constructor(data: Record<string, unknown>, client?: BiDiClient);
|
|
362
|
+
/** The response URL. */
|
|
363
|
+
url(): string;
|
|
364
|
+
/** The HTTP status code. */
|
|
365
|
+
status(): number;
|
|
366
|
+
/** Response headers as a simple key-value object. */
|
|
367
|
+
headers(): Record<string, string>;
|
|
368
|
+
/** The request ID associated with this response. */
|
|
369
|
+
requestId(): string;
|
|
370
|
+
/** Response body as a string. Requires a data collector (set up by onResponse/expect.response). */
|
|
371
|
+
body(): Promise<string | null>;
|
|
372
|
+
/** Response body parsed as JSON. Requires a data collector (set up by onResponse/expect.response). */
|
|
373
|
+
json(): Promise<unknown>;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Represents an intercepted network request that can be fulfilled, continued, or aborted. */
|
|
377
|
+
declare class Route {
|
|
378
|
+
readonly request: Request;
|
|
379
|
+
private client;
|
|
380
|
+
private requestId;
|
|
381
|
+
constructor(client: BiDiClient, requestId: string, request: Request);
|
|
382
|
+
/** Fulfill the request with a custom response (mock response). */
|
|
383
|
+
fulfill(response?: {
|
|
384
|
+
status?: number;
|
|
385
|
+
headers?: Record<string, string>;
|
|
386
|
+
contentType?: string;
|
|
387
|
+
body?: string;
|
|
388
|
+
}): Promise<void>;
|
|
389
|
+
/** Continue the request with optional overrides. */
|
|
390
|
+
continue(overrides?: {
|
|
391
|
+
url?: string;
|
|
392
|
+
method?: string;
|
|
393
|
+
headers?: Record<string, string>;
|
|
394
|
+
postData?: string;
|
|
395
|
+
}): Promise<void>;
|
|
396
|
+
/** Abort the request. */
|
|
397
|
+
abort(): Promise<void>;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** Represents a browser dialog (alert, confirm, prompt, beforeunload). */
|
|
401
|
+
declare class Dialog {
|
|
402
|
+
private client;
|
|
403
|
+
private contextId;
|
|
404
|
+
private data;
|
|
405
|
+
constructor(client: BiDiClient, contextId: string, data: Record<string, unknown>);
|
|
406
|
+
/** The dialog message text. */
|
|
407
|
+
message(): string;
|
|
408
|
+
/** The dialog type: 'alert', 'confirm', 'prompt', or 'beforeunload'. */
|
|
409
|
+
type(): string;
|
|
410
|
+
/** The default value for prompt dialogs. */
|
|
411
|
+
defaultValue(): string;
|
|
412
|
+
/** Accept the dialog. For prompt dialogs, optionally provide text. */
|
|
413
|
+
accept(promptText?: string): Promise<void>;
|
|
414
|
+
/** Dismiss the dialog (cancel/close). */
|
|
415
|
+
dismiss(): Promise<void>;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/** Represents a single console message from the page (console.log, warn, error, etc.). */
|
|
419
|
+
declare class ConsoleMessage {
|
|
420
|
+
private data;
|
|
421
|
+
constructor(data: Record<string, unknown>);
|
|
422
|
+
/** The console method: 'log', 'warn', 'error', 'debug', 'info', etc. */
|
|
423
|
+
type(): string;
|
|
424
|
+
/** The message text. */
|
|
425
|
+
text(): string;
|
|
426
|
+
/** The serialized arguments passed to the console call. */
|
|
427
|
+
args(): unknown[];
|
|
428
|
+
/** The source location of the console call, if available. */
|
|
429
|
+
location(): {
|
|
430
|
+
url: string;
|
|
431
|
+
lineNumber: number;
|
|
432
|
+
columnNumber: number;
|
|
433
|
+
} | null;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Represents a file download triggered by the page. */
|
|
437
|
+
declare class Download {
|
|
438
|
+
private client;
|
|
439
|
+
private _url;
|
|
440
|
+
private _suggestedFilename;
|
|
441
|
+
private _resolve;
|
|
442
|
+
private _completionPromise;
|
|
443
|
+
constructor(client: BiDiClient, url: string, suggestedFilename: string);
|
|
444
|
+
/** The URL of the download. */
|
|
445
|
+
url(): string;
|
|
446
|
+
/** The filename suggested by the server (from Content-Disposition). */
|
|
447
|
+
suggestedFilename(): string;
|
|
448
|
+
/** Wait for the download completion promise with a timeout. */
|
|
449
|
+
private _waitForCompletion;
|
|
450
|
+
/** Wait for the download to complete, then save to the specified path. */
|
|
451
|
+
saveAs(path: string): Promise<void>;
|
|
452
|
+
/** Wait for the download to complete and return the temp file path, or null if failed. */
|
|
453
|
+
path(): Promise<string | null>;
|
|
454
|
+
/** Internal: called by Page when downloadCompleted fires. */
|
|
455
|
+
_complete(status: string, filepath: string | null): void;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
type MessageHandler$1 = (data: string, info: {
|
|
459
|
+
direction: 'sent' | 'received';
|
|
460
|
+
}) => void;
|
|
461
|
+
type CloseHandler$1 = (code?: number, reason?: string) => void;
|
|
462
|
+
declare class WebSocketInfo {
|
|
463
|
+
private _url;
|
|
464
|
+
private _isClosed;
|
|
465
|
+
private messageHandlers;
|
|
466
|
+
private closeHandlers;
|
|
467
|
+
constructor(url: string);
|
|
468
|
+
url(): string;
|
|
469
|
+
onMessage(fn: MessageHandler$1): void;
|
|
470
|
+
onClose(fn: CloseHandler$1): void;
|
|
471
|
+
isClosed(): boolean;
|
|
472
|
+
/** @internal */
|
|
473
|
+
_emitMessage(data: string, direction: 'sent' | 'received'): void;
|
|
474
|
+
/** @internal */
|
|
475
|
+
_emitClose(code?: number, reason?: string): void;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
interface ClockInstallOptions$1 {
|
|
479
|
+
/** Initial time as epoch ms, ISO date string, or Date object. */
|
|
480
|
+
time?: number | string | Date;
|
|
481
|
+
/** IANA timezone ID to override (e.g. "America/New_York", "Europe/London"). */
|
|
482
|
+
timezone?: string;
|
|
483
|
+
}
|
|
484
|
+
/** Page-scoped clock control for faking timers and Date. */
|
|
485
|
+
declare class Clock {
|
|
486
|
+
private client;
|
|
487
|
+
private contextId;
|
|
488
|
+
constructor(client: BiDiClient, contextId: string);
|
|
489
|
+
/** Install fake clock, overriding Date, setTimeout, setInterval, etc. */
|
|
490
|
+
install(options?: ClockInstallOptions$1): Promise<void>;
|
|
491
|
+
/** Jump forward by ticks ms, fire each due timer at most once. */
|
|
492
|
+
fastForward(ticks: number): Promise<void>;
|
|
493
|
+
/** Advance ticks ms, firing all callbacks systematically (including interval reschedules). */
|
|
494
|
+
runFor(ticks: number): Promise<void>;
|
|
495
|
+
/** Jump to a specific time and pause — no timers fire until resumed/advanced. */
|
|
496
|
+
pauseAt(time: number | string | Date): Promise<void>;
|
|
497
|
+
/** Resume real-time progression from current fake time. */
|
|
498
|
+
resume(): Promise<void>;
|
|
499
|
+
/** Freeze Date.now() at a value permanently. Timers still run. */
|
|
500
|
+
setFixedTime(time: number | string | Date): Promise<void>;
|
|
501
|
+
/** Set Date.now() without triggering timers. */
|
|
502
|
+
setSystemTime(time: number | string | Date): Promise<void>;
|
|
503
|
+
/** Override the browser timezone. Pass an IANA timezone ID, or empty string to reset to system default. */
|
|
504
|
+
setTimezone(timezone: string): Promise<void>;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
interface FindOptions {
|
|
508
|
+
/** Timeout in milliseconds to wait for element. Default: 30000 */
|
|
509
|
+
timeout?: number;
|
|
510
|
+
}
|
|
511
|
+
interface ScreenshotOptions {
|
|
512
|
+
/** Capture full scrollable page instead of just the viewport. */
|
|
513
|
+
fullPage?: boolean;
|
|
514
|
+
/** Capture a specific region of the page. */
|
|
515
|
+
clip?: {
|
|
516
|
+
x: number;
|
|
517
|
+
y: number;
|
|
518
|
+
width: number;
|
|
519
|
+
height: number;
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
declare const customInspect$4: unique symbol;
|
|
523
|
+
/** Page-level keyboard input. */
|
|
524
|
+
declare class Keyboard {
|
|
525
|
+
private client;
|
|
526
|
+
private contextId;
|
|
527
|
+
constructor(client: BiDiClient, contextId: string);
|
|
528
|
+
/** Press and release a key. Supports combos like "Control+a". */
|
|
529
|
+
press(key: string): Promise<void>;
|
|
530
|
+
/** Press a key down (without releasing). */
|
|
531
|
+
down(key: string): Promise<void>;
|
|
532
|
+
/** Release a key. */
|
|
533
|
+
up(key: string): Promise<void>;
|
|
534
|
+
/** Type a string of text character by character. */
|
|
535
|
+
type(text: string): Promise<void>;
|
|
536
|
+
}
|
|
537
|
+
/** Page-level mouse input. */
|
|
538
|
+
declare class Mouse {
|
|
539
|
+
private client;
|
|
540
|
+
private contextId;
|
|
541
|
+
constructor(client: BiDiClient, contextId: string);
|
|
542
|
+
/** Click at (x, y) coordinates. */
|
|
543
|
+
click(x: number, y: number): Promise<void>;
|
|
544
|
+
/** Move mouse to (x, y) coordinates. */
|
|
545
|
+
move(x: number, y: number): Promise<void>;
|
|
546
|
+
/** Press mouse button down. */
|
|
547
|
+
down(): Promise<void>;
|
|
548
|
+
/** Release mouse button. */
|
|
549
|
+
up(): Promise<void>;
|
|
550
|
+
/** Scroll the mouse wheel. */
|
|
551
|
+
wheel(deltaX: number, deltaY: number): Promise<void>;
|
|
552
|
+
}
|
|
553
|
+
/** Page-level touch input. */
|
|
554
|
+
declare class Touch {
|
|
555
|
+
private client;
|
|
556
|
+
private contextId;
|
|
557
|
+
constructor(client: BiDiClient, contextId: string);
|
|
558
|
+
/** Tap at (x, y) coordinates. */
|
|
559
|
+
tap(x: number, y: number): Promise<void>;
|
|
560
|
+
}
|
|
561
|
+
interface A11yNode {
|
|
562
|
+
role: string;
|
|
563
|
+
name?: string;
|
|
564
|
+
value?: string | number;
|
|
565
|
+
description?: string;
|
|
566
|
+
disabled?: boolean;
|
|
567
|
+
expanded?: boolean;
|
|
568
|
+
focused?: boolean;
|
|
569
|
+
checked?: boolean | 'mixed';
|
|
570
|
+
pressed?: boolean | 'mixed';
|
|
571
|
+
selected?: boolean;
|
|
572
|
+
required?: boolean;
|
|
573
|
+
readonly?: boolean;
|
|
574
|
+
level?: number;
|
|
575
|
+
valuemin?: number;
|
|
576
|
+
valuemax?: number;
|
|
577
|
+
children?: A11yNode[];
|
|
578
|
+
}
|
|
579
|
+
declare class Page {
|
|
580
|
+
private client;
|
|
581
|
+
private contextId;
|
|
582
|
+
private _context;
|
|
583
|
+
/** Page-level keyboard input. */
|
|
584
|
+
readonly keyboard: Keyboard;
|
|
585
|
+
/** Page-level mouse input. */
|
|
586
|
+
readonly mouse: Mouse;
|
|
587
|
+
/** Page-level touch input. */
|
|
588
|
+
readonly touch: Touch;
|
|
589
|
+
/** Page-level clock control for faking timers and Date. */
|
|
590
|
+
readonly clock: Clock;
|
|
591
|
+
private routes;
|
|
592
|
+
private requestCallbacks;
|
|
593
|
+
private responseCallbacks;
|
|
594
|
+
private dialogCallbacks;
|
|
595
|
+
private consoleCallbacks;
|
|
596
|
+
private errorCallbacks;
|
|
597
|
+
private downloadCallbacks;
|
|
598
|
+
private navigationCallbacks;
|
|
599
|
+
private pendingDownloads;
|
|
600
|
+
private wsCallbacks;
|
|
601
|
+
private wsConnections;
|
|
602
|
+
private eventHandler;
|
|
603
|
+
private interceptId;
|
|
604
|
+
private dataCollectorId;
|
|
605
|
+
private _consoleBuffer;
|
|
606
|
+
private _errorBuffer;
|
|
607
|
+
constructor(client: BiDiClient, contextId: string, userContextId?: string);
|
|
608
|
+
/** The browsing context ID for this page. */
|
|
609
|
+
get id(): string;
|
|
610
|
+
[customInspect$4](): string;
|
|
611
|
+
/** The parent BrowserContext that owns this page. */
|
|
612
|
+
get context(): BrowserContext;
|
|
613
|
+
/** Navigate to a URL. */
|
|
614
|
+
go(url: string): Promise<void>;
|
|
615
|
+
/** Navigate back in history. */
|
|
616
|
+
back(): Promise<void>;
|
|
617
|
+
/** Navigate forward in history. */
|
|
618
|
+
forward(): Promise<void>;
|
|
619
|
+
/** Reload the page. */
|
|
620
|
+
reload(): Promise<void>;
|
|
621
|
+
/** Get the current page URL. */
|
|
622
|
+
url(): Promise<string>;
|
|
623
|
+
/** Get the current page title. */
|
|
624
|
+
title(): Promise<string>;
|
|
625
|
+
/** Get the full HTML content of the page. */
|
|
626
|
+
content(): Promise<string>;
|
|
627
|
+
/** @internal Wait until the page URL matches a pattern. */
|
|
628
|
+
_waitForURL(pattern: string, options?: {
|
|
629
|
+
timeout?: number;
|
|
630
|
+
}): Promise<void>;
|
|
631
|
+
/** @internal Wait until the page reaches a load state. */
|
|
632
|
+
_waitForLoad(state?: string, options?: {
|
|
633
|
+
timeout?: number;
|
|
634
|
+
}): Promise<void>;
|
|
635
|
+
/** Get all child frames of this page (recursive, flattened). */
|
|
636
|
+
frames(): Promise<Page[]>;
|
|
637
|
+
/** Find a frame by name attribute or URL substring. Returns null if not found. */
|
|
638
|
+
frame(nameOrUrl: string): Promise<Page | null>;
|
|
639
|
+
/** Returns this page — the page IS its own main frame. */
|
|
640
|
+
mainFrame(): Page;
|
|
641
|
+
/** Set the viewport size. */
|
|
642
|
+
setViewport(size: {
|
|
643
|
+
width: number;
|
|
644
|
+
height: number;
|
|
645
|
+
}): Promise<void>;
|
|
646
|
+
/** Get the current viewport size. */
|
|
647
|
+
viewport(): Promise<{
|
|
648
|
+
width: number;
|
|
649
|
+
height: number;
|
|
650
|
+
}>;
|
|
651
|
+
/** Override CSS media features (colorScheme, reducedMotion, forcedColors, contrast, media type). */
|
|
652
|
+
emulateMedia(opts: {
|
|
653
|
+
media?: 'screen' | 'print' | null;
|
|
654
|
+
colorScheme?: 'light' | 'dark' | 'no-preference' | null;
|
|
655
|
+
reducedMotion?: 'reduce' | 'no-preference' | null;
|
|
656
|
+
forcedColors?: 'active' | 'none' | null;
|
|
657
|
+
contrast?: 'more' | 'no-preference' | null;
|
|
658
|
+
}): Promise<void>;
|
|
659
|
+
/** Replace the page HTML content. */
|
|
660
|
+
setContent(html: string): Promise<void>;
|
|
661
|
+
/** Override the browser's geolocation. */
|
|
662
|
+
setGeolocation(coords: {
|
|
663
|
+
latitude: number;
|
|
664
|
+
longitude: number;
|
|
665
|
+
accuracy?: number;
|
|
666
|
+
}): Promise<void>;
|
|
667
|
+
/** Set the OS browser window size, position, or state. */
|
|
668
|
+
setWindow(options: {
|
|
669
|
+
width?: number;
|
|
670
|
+
height?: number;
|
|
671
|
+
x?: number;
|
|
672
|
+
y?: number;
|
|
673
|
+
state?: 'normal' | 'maximized' | 'minimized' | 'fullscreen';
|
|
674
|
+
}): Promise<void>;
|
|
675
|
+
/** Get the current OS browser window state and dimensions. */
|
|
676
|
+
window(): Promise<{
|
|
677
|
+
state: string;
|
|
678
|
+
width: number;
|
|
679
|
+
height: number;
|
|
680
|
+
x: number;
|
|
681
|
+
y: number;
|
|
682
|
+
}>;
|
|
683
|
+
/** Get the accessibility tree for the page. */
|
|
684
|
+
a11yTree(options?: {
|
|
685
|
+
everything?: boolean;
|
|
686
|
+
root?: string;
|
|
687
|
+
}): Promise<A11yNode>;
|
|
688
|
+
/** Bring this page/tab to the foreground. */
|
|
689
|
+
bringToFront(): Promise<void>;
|
|
690
|
+
/** Close this page/tab. */
|
|
691
|
+
close(): Promise<void>;
|
|
692
|
+
/** Scroll the page in a direction. */
|
|
693
|
+
scroll(direction?: string, amount?: number, selector?: string): Promise<void>;
|
|
694
|
+
/** Take a screenshot of the page. Returns a PNG buffer. */
|
|
695
|
+
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
696
|
+
/** Print the page to PDF. Returns a PDF buffer. Only works in headless mode. */
|
|
697
|
+
pdf(): Promise<Buffer>;
|
|
698
|
+
/** Evaluate a JS expression and return the deserialized value. */
|
|
699
|
+
evaluate<T = unknown>(expression: string): Promise<T>;
|
|
700
|
+
/** Inject a script into the page. Pass a URL or inline JavaScript. */
|
|
701
|
+
addScript(source: string): Promise<void>;
|
|
702
|
+
/** Inject a stylesheet into the page. Pass a URL or inline CSS. */
|
|
703
|
+
addStyle(source: string): Promise<void>;
|
|
704
|
+
/** Expose a function on window. The function body is injected as a string. */
|
|
705
|
+
expose(name: string, fn: string): Promise<void>;
|
|
706
|
+
/** Capture namespace — set up a listener before performing an action. */
|
|
707
|
+
readonly capture: {
|
|
708
|
+
/** Capture a response matching a URL pattern. Optionally pass fn to trigger the action. */
|
|
709
|
+
response(pattern: string, fn?: () => Promise<void>, options?: {
|
|
710
|
+
timeout?: number;
|
|
711
|
+
}): Promise<Response>;
|
|
712
|
+
/** Capture a request matching a URL pattern. Optionally pass fn to trigger the action. */
|
|
713
|
+
request(pattern: string, fn?: () => Promise<void>, options?: {
|
|
714
|
+
timeout?: number;
|
|
715
|
+
}): Promise<Request>;
|
|
716
|
+
/** Capture a navigation event. Optionally pass fn to trigger the action. Resolves with URL. */
|
|
717
|
+
navigation(fn?: () => Promise<void>, options?: {
|
|
718
|
+
timeout?: number;
|
|
719
|
+
}): Promise<string>;
|
|
720
|
+
/** Capture a download. Optionally pass fn to trigger the action. */
|
|
721
|
+
download(fn?: () => Promise<void>, options?: {
|
|
722
|
+
timeout?: number;
|
|
723
|
+
}): Promise<Download>;
|
|
724
|
+
/** Capture a dialog. Optionally pass fn to trigger the action. */
|
|
725
|
+
dialog(fn?: () => Promise<void>, options?: {
|
|
726
|
+
timeout?: number;
|
|
727
|
+
}): Promise<Dialog>;
|
|
728
|
+
/** Capture a named event. Optionally pass fn to trigger the action. */
|
|
729
|
+
event(name: string, fn?: () => Promise<void>, options?: {
|
|
730
|
+
timeout?: number;
|
|
731
|
+
}): Promise<unknown>;
|
|
732
|
+
};
|
|
733
|
+
/** Wait until a condition is met. Callable with a function, or use .url() / .loaded() sub-methods. */
|
|
734
|
+
readonly waitUntil: ((fn: string, options?: {
|
|
735
|
+
timeout?: number;
|
|
736
|
+
}) => Promise<unknown>) & {
|
|
737
|
+
/** Wait until the page URL matches a pattern. */
|
|
738
|
+
url(pattern: string, options?: {
|
|
739
|
+
timeout?: number;
|
|
740
|
+
}): Promise<void>;
|
|
741
|
+
/** Wait until the page reaches a load state. */
|
|
742
|
+
loaded(state?: string, options?: {
|
|
743
|
+
timeout?: number;
|
|
744
|
+
}): Promise<void>;
|
|
745
|
+
};
|
|
746
|
+
/** Wait for a fixed amount of time (milliseconds). Discouraged but useful for debugging. */
|
|
747
|
+
wait(ms: number): Promise<void>;
|
|
748
|
+
/** @internal Wait until a function returns a truthy value. */
|
|
749
|
+
_waitForFunction<T = unknown>(fn: string, options?: {
|
|
750
|
+
timeout?: number;
|
|
751
|
+
}): Promise<T>;
|
|
752
|
+
/** Find an element by CSS selector or semantic options. Waits for element to exist. */
|
|
753
|
+
find(selector: string | SelectorOptions, options?: FindOptions): FluentElement;
|
|
754
|
+
/** Find all elements matching a CSS selector or semantic options. Waits for at least one. */
|
|
755
|
+
findAll(selector: string | SelectorOptions, options?: FindOptions): Promise<Element[]>;
|
|
756
|
+
/**
|
|
757
|
+
* Intercept network requests matching a URL pattern.
|
|
758
|
+
* The handler receives a Route object that can fulfill, continue, or abort the request.
|
|
759
|
+
*/
|
|
760
|
+
route(pattern: string, handler: (route: Route) => void): Promise<void>;
|
|
761
|
+
/** Remove a previously registered route. If no handler given, removes all routes for the pattern. */
|
|
762
|
+
unroute(pattern: string): Promise<void>;
|
|
763
|
+
/** Register a callback for every outgoing request. */
|
|
764
|
+
onRequest(fn: (request: Request) => void): void;
|
|
765
|
+
/** Register a callback for every completed response. */
|
|
766
|
+
onResponse(fn: (response: Response) => void): void;
|
|
767
|
+
/**
|
|
768
|
+
* Remove all listeners for a given event, or all events if no event specified.
|
|
769
|
+
* Supported events: 'request', 'response', 'dialog', 'console', 'error', 'download', 'websocket'.
|
|
770
|
+
*/
|
|
771
|
+
removeAllListeners(event?: 'request' | 'response' | 'dialog' | 'console' | 'error' | 'download' | 'navigation' | 'websocket'): void;
|
|
772
|
+
/** @internal Capture a request matching a URL pattern. */
|
|
773
|
+
_captureRequest(pattern: string, options?: {
|
|
774
|
+
timeout?: number;
|
|
775
|
+
}): Promise<Request>;
|
|
776
|
+
/** @internal Capture a response matching a URL pattern. */
|
|
777
|
+
_captureResponse(pattern: string, options?: {
|
|
778
|
+
timeout?: number;
|
|
779
|
+
}): Promise<Response>;
|
|
780
|
+
/** @internal Capture a navigation event. Resolves with the URL. */
|
|
781
|
+
_captureNavigation(options?: {
|
|
782
|
+
timeout?: number;
|
|
783
|
+
}): Promise<string>;
|
|
784
|
+
/** @internal Capture a download event. */
|
|
785
|
+
_captureDownload(options?: {
|
|
786
|
+
timeout?: number;
|
|
787
|
+
}): Promise<Download>;
|
|
788
|
+
/** @internal Capture a dialog event. The registered callback prevents auto-dismiss. */
|
|
789
|
+
_captureDialog(options?: {
|
|
790
|
+
timeout?: number;
|
|
791
|
+
}): Promise<Dialog>;
|
|
792
|
+
/** @internal Capture a named event. Maps event name to the appropriate callback array. */
|
|
793
|
+
_captureEvent(name: string, options?: {
|
|
794
|
+
timeout?: number;
|
|
795
|
+
}): Promise<unknown>;
|
|
796
|
+
/** Set extra HTTP headers for all requests in this page. */
|
|
797
|
+
setHeaders(headers: Record<string, string>): Promise<void>;
|
|
798
|
+
/** Intercept WebSocket connections. Not supported by BiDi. */
|
|
799
|
+
routeWebSocket(_pattern: string, _handler: unknown): never;
|
|
800
|
+
/** Listen for WebSocket connections opened by the page. */
|
|
801
|
+
onWebSocket(fn: (ws: WebSocketInfo) => void): void;
|
|
802
|
+
/**
|
|
803
|
+
* Register a handler for browser dialogs (alert, confirm, prompt).
|
|
804
|
+
* If no handler is registered, dialogs are automatically dismissed.
|
|
805
|
+
*/
|
|
806
|
+
onDialog(handler: (dialog: Dialog) => void): void;
|
|
807
|
+
/** Register a handler for console messages, or pass 'collect' to buffer them for consoleMessages(). */
|
|
808
|
+
onConsole(handler: ((message: ConsoleMessage) => void) | 'collect'): void;
|
|
809
|
+
/** Return collected console messages and clear the buffer. Returns [] if not collecting. */
|
|
810
|
+
consoleMessages(): {
|
|
811
|
+
type: string;
|
|
812
|
+
text: string;
|
|
813
|
+
}[];
|
|
814
|
+
/** Register a handler for uncaught page errors, or pass 'collect' to buffer them for errors(). */
|
|
815
|
+
onError(handler: ((error: Error) => void) | 'collect'): void;
|
|
816
|
+
/** Return collected errors and clear the buffer. Returns [] if not collecting. */
|
|
817
|
+
errors(): {
|
|
818
|
+
message: string;
|
|
819
|
+
}[];
|
|
820
|
+
/** Register a handler for file downloads. */
|
|
821
|
+
onDownload(handler: (download: Download) => void): void;
|
|
822
|
+
private ensureDataCollector;
|
|
823
|
+
private teardownDataCollector;
|
|
824
|
+
private handleBeforeRequestSent;
|
|
825
|
+
private handleResponseCompleted;
|
|
826
|
+
private handleUserPromptOpened;
|
|
827
|
+
private handleLogEntryAdded;
|
|
828
|
+
private handleDownloadWillBegin;
|
|
829
|
+
private handleDownloadCompleted;
|
|
830
|
+
private handleWsCreated;
|
|
831
|
+
private handleWsMessage;
|
|
832
|
+
private handleWsClosed;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
declare const customInspect$3: unique symbol;
|
|
836
|
+
interface StartOptions {
|
|
837
|
+
headless?: boolean;
|
|
838
|
+
headers?: Record<string, string>;
|
|
839
|
+
executablePath?: string;
|
|
840
|
+
}
|
|
841
|
+
declare class Browser {
|
|
842
|
+
private client;
|
|
843
|
+
private process;
|
|
844
|
+
private pageCallbacks;
|
|
845
|
+
private popupCallbacks;
|
|
846
|
+
constructor(client: BiDiClient, process: VibiumProcess | null);
|
|
847
|
+
[customInspect$3](): string;
|
|
848
|
+
/** Get the default page (first browsing context). */
|
|
849
|
+
page(): Promise<Page>;
|
|
850
|
+
/** Create a new page (tab) in the default context. */
|
|
851
|
+
newPage(): Promise<Page>;
|
|
852
|
+
/** Create a new browser context (isolated, incognito-like). */
|
|
853
|
+
newContext(): Promise<BrowserContext>;
|
|
854
|
+
/** Get all open pages. */
|
|
855
|
+
pages(): Promise<Page[]>;
|
|
856
|
+
/** Register a callback for when a new page is created (e.g. new tab). */
|
|
857
|
+
onPage(callback: (page: Page) => void): void;
|
|
858
|
+
/** Register a callback for when a popup is opened (window.open or target=_blank). */
|
|
859
|
+
onPopup(callback: (page: Page) => void): void;
|
|
860
|
+
/**
|
|
861
|
+
* Remove all listeners for a given event, or all events if no event specified.
|
|
862
|
+
* Supported events: 'page', 'popup'.
|
|
863
|
+
*/
|
|
864
|
+
removeAllListeners(event?: 'page' | 'popup'): void;
|
|
865
|
+
/** Stop the browser and clean up. */
|
|
866
|
+
stop(): Promise<void>;
|
|
867
|
+
}
|
|
868
|
+
declare const browser: {
|
|
869
|
+
start(urlOrOptions?: string | StartOptions, options?: StartOptions): Promise<Browser>;
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Signal protocol (2-slot SharedArrayBuffer):
|
|
874
|
+
* signal[0]: worker → main (0=idle, 1=result ready, 2=callback needed)
|
|
875
|
+
* signal[1]: main → worker (0=idle, 1=callback response ready)
|
|
876
|
+
*/
|
|
877
|
+
declare class SyncBridge {
|
|
878
|
+
private worker;
|
|
879
|
+
private signal;
|
|
880
|
+
private commandId;
|
|
881
|
+
private terminated;
|
|
882
|
+
private callbackPortMain;
|
|
883
|
+
private callbackPortWorker;
|
|
884
|
+
private handlers;
|
|
885
|
+
private constructor();
|
|
886
|
+
static create(): SyncBridge;
|
|
887
|
+
/** Register a callback handler that can be invoked from the worker thread. */
|
|
888
|
+
registerHandler(id: string, handler: Function): void;
|
|
889
|
+
/** Remove a previously registered callback handler. */
|
|
890
|
+
unregisterHandler(id: string): void;
|
|
891
|
+
/** Process any pending callbacks that fired between bridge calls. */
|
|
892
|
+
private processPendingCallbacks;
|
|
893
|
+
/** Handle a single callback request from the worker. */
|
|
894
|
+
private handleCallback;
|
|
895
|
+
call<T = unknown>(method: string, args?: unknown[]): T;
|
|
896
|
+
tryQuit(): void;
|
|
897
|
+
terminate(): void;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
declare const customInspect$2: unique symbol;
|
|
901
|
+
declare class ElementSync {
|
|
902
|
+
private bridge;
|
|
903
|
+
private elementId;
|
|
904
|
+
readonly info: ElementInfo;
|
|
905
|
+
constructor(bridge: SyncBridge, elementId: number, info: ElementInfo);
|
|
906
|
+
[customInspect$2](): string;
|
|
907
|
+
/**
|
|
908
|
+
* Click the element.
|
|
909
|
+
* Waits for element to be visible, stable, receive events, and enabled.
|
|
910
|
+
*/
|
|
911
|
+
click(options?: ActionOptions): void;
|
|
912
|
+
/** Double-click the element. */
|
|
913
|
+
dblclick(options?: ActionOptions): void;
|
|
914
|
+
/**
|
|
915
|
+
* Fill the element with text (clears existing content first).
|
|
916
|
+
* For inputs and textareas.
|
|
917
|
+
*/
|
|
918
|
+
fill(value: string, options?: ActionOptions): void;
|
|
919
|
+
/**
|
|
920
|
+
* Type text into the element.
|
|
921
|
+
* Waits for element to be visible, stable, receive events, enabled, and editable.
|
|
922
|
+
*/
|
|
923
|
+
type(text: string, options?: ActionOptions): void;
|
|
924
|
+
/**
|
|
925
|
+
* Press a key while the element is focused.
|
|
926
|
+
* Supports key names ("Enter", "Tab") and combos ("Control+a").
|
|
927
|
+
*/
|
|
928
|
+
press(key: string, options?: ActionOptions): void;
|
|
929
|
+
/** Clear the element's content (select all + delete). */
|
|
930
|
+
clear(options?: ActionOptions): void;
|
|
931
|
+
/** Check a checkbox (no-op if already checked). */
|
|
932
|
+
check(options?: ActionOptions): void;
|
|
933
|
+
/** Uncheck a checkbox (no-op if already unchecked). */
|
|
934
|
+
uncheck(options?: ActionOptions): void;
|
|
935
|
+
/** Select an option in a <select> element by value. */
|
|
936
|
+
selectOption(value: string, options?: ActionOptions): void;
|
|
937
|
+
/** Hover over the element (move mouse to center, no click). */
|
|
938
|
+
hover(options?: ActionOptions): void;
|
|
939
|
+
/** Focus the element. */
|
|
940
|
+
focus(options?: ActionOptions): void;
|
|
941
|
+
/** Drag this element to a target element. */
|
|
942
|
+
dragTo(target: ElementSync, options?: ActionOptions): void;
|
|
943
|
+
/** Tap the element (touch action). */
|
|
944
|
+
tap(options?: ActionOptions): void;
|
|
945
|
+
/** Scroll the element into view. */
|
|
946
|
+
scrollIntoView(options?: ActionOptions): void;
|
|
947
|
+
/** Dispatch a DOM event on the element. */
|
|
948
|
+
dispatchEvent(eventType: string, eventInit?: Record<string, unknown>, options?: ActionOptions): void;
|
|
949
|
+
text(): string;
|
|
950
|
+
innerText(): string;
|
|
951
|
+
html(): string;
|
|
952
|
+
value(): string;
|
|
953
|
+
attr(name: string): string | null;
|
|
954
|
+
getAttribute(name: string): string | null;
|
|
955
|
+
bounds(): BoundingBox;
|
|
956
|
+
boundingBox(): BoundingBox;
|
|
957
|
+
isVisible(): boolean;
|
|
958
|
+
isHidden(): boolean;
|
|
959
|
+
isEnabled(): boolean;
|
|
960
|
+
isChecked(): boolean;
|
|
961
|
+
isEditable(): boolean;
|
|
962
|
+
screenshot(): Buffer;
|
|
963
|
+
waitUntil(state?: string, options?: {
|
|
964
|
+
timeout?: number;
|
|
965
|
+
}): void;
|
|
966
|
+
setFiles(files: string[], options?: ActionOptions): void;
|
|
967
|
+
role(): string;
|
|
968
|
+
label(): string;
|
|
969
|
+
find(selector: string | SelectorOptions, options?: {
|
|
970
|
+
timeout?: number;
|
|
971
|
+
}): ElementSync;
|
|
972
|
+
findAll(selector: string | SelectorOptions, options?: {
|
|
973
|
+
timeout?: number;
|
|
974
|
+
}): ElementSync[];
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
declare class KeyboardSync {
|
|
978
|
+
private bridge;
|
|
979
|
+
private pageId;
|
|
980
|
+
constructor(bridge: SyncBridge, pageId: number);
|
|
981
|
+
press(key: string): void;
|
|
982
|
+
down(key: string): void;
|
|
983
|
+
up(key: string): void;
|
|
984
|
+
type(text: string): void;
|
|
985
|
+
}
|
|
986
|
+
declare class MouseSync {
|
|
987
|
+
private bridge;
|
|
988
|
+
private pageId;
|
|
989
|
+
constructor(bridge: SyncBridge, pageId: number);
|
|
990
|
+
click(x: number, y: number): void;
|
|
991
|
+
move(x: number, y: number): void;
|
|
992
|
+
down(): void;
|
|
993
|
+
up(): void;
|
|
994
|
+
wheel(deltaX: number, deltaY: number): void;
|
|
995
|
+
}
|
|
996
|
+
declare class TouchSync {
|
|
997
|
+
private bridge;
|
|
998
|
+
private pageId;
|
|
999
|
+
constructor(bridge: SyncBridge, pageId: number);
|
|
1000
|
+
tap(x: number, y: number): void;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
interface ClockInstallOptions {
|
|
1004
|
+
time?: number | string | Date;
|
|
1005
|
+
timezone?: string;
|
|
1006
|
+
}
|
|
1007
|
+
declare class ClockSync {
|
|
1008
|
+
private bridge;
|
|
1009
|
+
private pageId;
|
|
1010
|
+
constructor(bridge: SyncBridge, pageId: number);
|
|
1011
|
+
install(options?: ClockInstallOptions): void;
|
|
1012
|
+
fastForward(ticks: number): void;
|
|
1013
|
+
runFor(ticks: number): void;
|
|
1014
|
+
pauseAt(time: number | string | Date): void;
|
|
1015
|
+
resume(): void;
|
|
1016
|
+
setFixedTime(time: number | string | Date): void;
|
|
1017
|
+
setSystemTime(time: number | string | Date): void;
|
|
1018
|
+
setTimezone(timezone: string): void;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
declare class RecordingSync {
|
|
1022
|
+
private bridge;
|
|
1023
|
+
private contextId;
|
|
1024
|
+
constructor(bridge: SyncBridge, contextId: number);
|
|
1025
|
+
start(options?: RecordingStartOptions): void;
|
|
1026
|
+
stop(options?: RecordingStopOptions): Buffer;
|
|
1027
|
+
startChunk(options?: {
|
|
1028
|
+
name?: string;
|
|
1029
|
+
title?: string;
|
|
1030
|
+
}): void;
|
|
1031
|
+
stopChunk(options?: RecordingStopOptions): Buffer;
|
|
1032
|
+
startGroup(name: string, options?: {
|
|
1033
|
+
location?: {
|
|
1034
|
+
file: string;
|
|
1035
|
+
line?: number;
|
|
1036
|
+
column?: number;
|
|
1037
|
+
};
|
|
1038
|
+
}): void;
|
|
1039
|
+
stopGroup(): void;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
declare class BrowserContextSync {
|
|
1043
|
+
private bridge;
|
|
1044
|
+
private contextId;
|
|
1045
|
+
readonly recording: RecordingSync;
|
|
1046
|
+
constructor(bridge: SyncBridge, contextId: number);
|
|
1047
|
+
newPage(): PageSync;
|
|
1048
|
+
close(): void;
|
|
1049
|
+
cookies(urls?: string[]): Cookie[];
|
|
1050
|
+
setCookies(cookies: SetCookieParam[]): void;
|
|
1051
|
+
clearCookies(): void;
|
|
1052
|
+
storage(): StorageState;
|
|
1053
|
+
setStorage(state: StorageState): void;
|
|
1054
|
+
clearStorage(): void;
|
|
1055
|
+
addInitScript(script: string): string;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/** Sync route handler data — plain object representing the intercepted request. */
|
|
1059
|
+
interface RouteRequest {
|
|
1060
|
+
url: string;
|
|
1061
|
+
method: string;
|
|
1062
|
+
headers: Record<string, string>;
|
|
1063
|
+
postData: string | null;
|
|
1064
|
+
}
|
|
1065
|
+
/** Decision returned by a sync route handler. */
|
|
1066
|
+
interface RouteDecision {
|
|
1067
|
+
action: 'fulfill' | 'continue' | 'abort';
|
|
1068
|
+
status?: number;
|
|
1069
|
+
headers?: Record<string, string>;
|
|
1070
|
+
contentType?: string;
|
|
1071
|
+
body?: string;
|
|
1072
|
+
url?: string;
|
|
1073
|
+
method?: string;
|
|
1074
|
+
postData?: string;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Sync wrapper for an intercepted network request.
|
|
1078
|
+
* The user's handler calls fulfill(), continue(), or abort() to set the decision.
|
|
1079
|
+
* If none is called, the default is 'continue'.
|
|
1080
|
+
*/
|
|
1081
|
+
declare class RouteSync {
|
|
1082
|
+
readonly request: RouteRequest;
|
|
1083
|
+
/** @internal */
|
|
1084
|
+
_decision: RouteDecision;
|
|
1085
|
+
constructor(request: RouteRequest);
|
|
1086
|
+
/** Fulfill the request with a custom response. */
|
|
1087
|
+
fulfill(response?: {
|
|
1088
|
+
status?: number;
|
|
1089
|
+
headers?: Record<string, string>;
|
|
1090
|
+
contentType?: string;
|
|
1091
|
+
body?: string;
|
|
1092
|
+
}): void;
|
|
1093
|
+
/** Continue the request, optionally with overrides. */
|
|
1094
|
+
continue(overrides?: {
|
|
1095
|
+
url?: string;
|
|
1096
|
+
method?: string;
|
|
1097
|
+
headers?: Record<string, string>;
|
|
1098
|
+
postData?: string;
|
|
1099
|
+
}): void;
|
|
1100
|
+
/** Abort the request. */
|
|
1101
|
+
abort(): void;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/** Serialized dialog data sent from worker to main thread. */
|
|
1105
|
+
interface DialogData {
|
|
1106
|
+
type: string;
|
|
1107
|
+
message: string;
|
|
1108
|
+
defaultValue: string;
|
|
1109
|
+
}
|
|
1110
|
+
/** Decision returned by a sync dialog handler. */
|
|
1111
|
+
interface DialogDecision {
|
|
1112
|
+
action: 'accept' | 'dismiss';
|
|
1113
|
+
promptText?: string;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Sync wrapper for a browser dialog (alert, confirm, prompt, beforeunload).
|
|
1117
|
+
* The user's handler calls accept() or dismiss() to set the decision.
|
|
1118
|
+
* If none is called, the default is 'dismiss'.
|
|
1119
|
+
*/
|
|
1120
|
+
declare class DialogSync {
|
|
1121
|
+
private data;
|
|
1122
|
+
/** @internal */
|
|
1123
|
+
_decision: DialogDecision;
|
|
1124
|
+
constructor(data: DialogData);
|
|
1125
|
+
/** The dialog type: 'alert', 'confirm', 'prompt', or 'beforeunload'. */
|
|
1126
|
+
type(): string;
|
|
1127
|
+
/** The dialog message text. */
|
|
1128
|
+
message(): string;
|
|
1129
|
+
/** The default value for prompt dialogs. */
|
|
1130
|
+
defaultValue(): string;
|
|
1131
|
+
/** Accept the dialog. For prompt dialogs, optionally provide text. */
|
|
1132
|
+
accept(promptText?: string): void;
|
|
1133
|
+
/** Dismiss the dialog (cancel/close). */
|
|
1134
|
+
dismiss(): void;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
declare const customInspect$1: unique symbol;
|
|
1138
|
+
interface RequestData {
|
|
1139
|
+
url: string;
|
|
1140
|
+
method: string;
|
|
1141
|
+
headers: Record<string, string>;
|
|
1142
|
+
postData: string | null;
|
|
1143
|
+
}
|
|
1144
|
+
interface ResponseData {
|
|
1145
|
+
url: string;
|
|
1146
|
+
status: number;
|
|
1147
|
+
headers: Record<string, string>;
|
|
1148
|
+
body: string | null;
|
|
1149
|
+
}
|
|
1150
|
+
declare class DownloadData {
|
|
1151
|
+
readonly url: string;
|
|
1152
|
+
readonly suggestedFilename: string;
|
|
1153
|
+
readonly path: string | null;
|
|
1154
|
+
constructor(data: {
|
|
1155
|
+
url: string;
|
|
1156
|
+
suggestedFilename: string;
|
|
1157
|
+
path: string | null;
|
|
1158
|
+
});
|
|
1159
|
+
/** Save the downloaded file to a destination path. */
|
|
1160
|
+
saveAs(destPath: string): void;
|
|
1161
|
+
}
|
|
1162
|
+
type MessageHandler = (data: string, info: {
|
|
1163
|
+
direction: 'sent' | 'received';
|
|
1164
|
+
}) => void;
|
|
1165
|
+
type CloseHandler = (code?: number, reason?: string) => void;
|
|
1166
|
+
declare class WebSocketInfoSync {
|
|
1167
|
+
private _url;
|
|
1168
|
+
private _isClosed;
|
|
1169
|
+
private _messageHandlers;
|
|
1170
|
+
private _closeHandlers;
|
|
1171
|
+
constructor(url: string);
|
|
1172
|
+
url(): string;
|
|
1173
|
+
onMessage(fn: MessageHandler): void;
|
|
1174
|
+
onClose(fn: CloseHandler): void;
|
|
1175
|
+
isClosed(): boolean;
|
|
1176
|
+
/** @internal */
|
|
1177
|
+
_emitMessage(data: string, direction: 'sent' | 'received'): void;
|
|
1178
|
+
/** @internal */
|
|
1179
|
+
_emitClose(code?: number, reason?: string): void;
|
|
1180
|
+
}
|
|
1181
|
+
declare class PageSync {
|
|
1182
|
+
/** @internal */
|
|
1183
|
+
readonly _bridge: SyncBridge;
|
|
1184
|
+
/** @internal */
|
|
1185
|
+
readonly _pageId: number;
|
|
1186
|
+
readonly keyboard: KeyboardSync;
|
|
1187
|
+
readonly mouse: MouseSync;
|
|
1188
|
+
readonly touch: TouchSync;
|
|
1189
|
+
readonly clock: ClockSync;
|
|
1190
|
+
private _nextHandlerId;
|
|
1191
|
+
private _routeHandlerIds;
|
|
1192
|
+
private _dialogHandlerId;
|
|
1193
|
+
private _requestHandlerId;
|
|
1194
|
+
private _responseHandlerId;
|
|
1195
|
+
private _downloadHandlerId;
|
|
1196
|
+
private _wsHandlerId;
|
|
1197
|
+
private _wsInstances;
|
|
1198
|
+
private _cachedContext;
|
|
1199
|
+
constructor(bridge: SyncBridge, pageId: number);
|
|
1200
|
+
[customInspect$1](): string;
|
|
1201
|
+
/** The parent BrowserContext that owns this page. */
|
|
1202
|
+
get context(): BrowserContextSync;
|
|
1203
|
+
go(url: string): void;
|
|
1204
|
+
back(): void;
|
|
1205
|
+
forward(): void;
|
|
1206
|
+
reload(): void;
|
|
1207
|
+
url(): string;
|
|
1208
|
+
title(): string;
|
|
1209
|
+
content(): string;
|
|
1210
|
+
find(selector: string | SelectorOptions, options?: FindOptions): ElementSync;
|
|
1211
|
+
findAll(selector: string | SelectorOptions, options?: FindOptions): ElementSync[];
|
|
1212
|
+
/** Capture namespace — set up a listener before performing an action. */
|
|
1213
|
+
get capture(): {
|
|
1214
|
+
response(pattern: string, fn?: () => void, options?: {
|
|
1215
|
+
timeout?: number;
|
|
1216
|
+
}): {
|
|
1217
|
+
url: string;
|
|
1218
|
+
status: number;
|
|
1219
|
+
headers: Record<string, string>;
|
|
1220
|
+
body: string | null;
|
|
1221
|
+
};
|
|
1222
|
+
request(pattern: string, fn?: () => void, options?: {
|
|
1223
|
+
timeout?: number;
|
|
1224
|
+
}): {
|
|
1225
|
+
url: string;
|
|
1226
|
+
method: string;
|
|
1227
|
+
headers: Record<string, string>;
|
|
1228
|
+
postData: string | null;
|
|
1229
|
+
};
|
|
1230
|
+
navigation(fn?: () => void, options?: {
|
|
1231
|
+
timeout?: number;
|
|
1232
|
+
}): {
|
|
1233
|
+
url: string;
|
|
1234
|
+
};
|
|
1235
|
+
download(fn?: () => void, options?: {
|
|
1236
|
+
timeout?: number;
|
|
1237
|
+
}): DownloadData;
|
|
1238
|
+
dialog(fn?: () => void, options?: {
|
|
1239
|
+
timeout?: number;
|
|
1240
|
+
}): {
|
|
1241
|
+
type: string;
|
|
1242
|
+
message: string;
|
|
1243
|
+
defaultValue: string;
|
|
1244
|
+
};
|
|
1245
|
+
event(name: string, fn?: () => void, options?: {
|
|
1246
|
+
timeout?: number;
|
|
1247
|
+
}): unknown;
|
|
1248
|
+
};
|
|
1249
|
+
/** Wait until a condition is met. Callable with a function, or use .url() / .loaded() sub-methods. */
|
|
1250
|
+
readonly waitUntil: ((fn: string, options?: {
|
|
1251
|
+
timeout?: number;
|
|
1252
|
+
}) => unknown) & {
|
|
1253
|
+
url(pattern: string, options?: {
|
|
1254
|
+
timeout?: number;
|
|
1255
|
+
}): void;
|
|
1256
|
+
loaded(state?: string, options?: {
|
|
1257
|
+
timeout?: number;
|
|
1258
|
+
}): void;
|
|
1259
|
+
};
|
|
1260
|
+
wait(ms: number): void;
|
|
1261
|
+
screenshot(options?: ScreenshotOptions): Buffer;
|
|
1262
|
+
pdf(): Buffer;
|
|
1263
|
+
evaluate<T = unknown>(expression: string): T;
|
|
1264
|
+
addScript(source: string): void;
|
|
1265
|
+
addStyle(source: string): void;
|
|
1266
|
+
expose(name: string, fn: string): void;
|
|
1267
|
+
bringToFront(): void;
|
|
1268
|
+
close(): void;
|
|
1269
|
+
scroll(direction?: string, amount?: number, selector?: string): void;
|
|
1270
|
+
setViewport(size: {
|
|
1271
|
+
width: number;
|
|
1272
|
+
height: number;
|
|
1273
|
+
}): void;
|
|
1274
|
+
viewport(): {
|
|
1275
|
+
width: number;
|
|
1276
|
+
height: number;
|
|
1277
|
+
};
|
|
1278
|
+
emulateMedia(opts: {
|
|
1279
|
+
media?: 'screen' | 'print' | null;
|
|
1280
|
+
colorScheme?: 'light' | 'dark' | 'no-preference' | null;
|
|
1281
|
+
reducedMotion?: 'reduce' | 'no-preference' | null;
|
|
1282
|
+
forcedColors?: 'active' | 'none' | null;
|
|
1283
|
+
contrast?: 'more' | 'no-preference' | null;
|
|
1284
|
+
}): void;
|
|
1285
|
+
setContent(html: string): void;
|
|
1286
|
+
setGeolocation(coords: {
|
|
1287
|
+
latitude: number;
|
|
1288
|
+
longitude: number;
|
|
1289
|
+
accuracy?: number;
|
|
1290
|
+
}): void;
|
|
1291
|
+
setWindow(options: {
|
|
1292
|
+
width?: number;
|
|
1293
|
+
height?: number;
|
|
1294
|
+
x?: number;
|
|
1295
|
+
y?: number;
|
|
1296
|
+
state?: 'normal' | 'maximized' | 'minimized' | 'fullscreen';
|
|
1297
|
+
}): void;
|
|
1298
|
+
window(): {
|
|
1299
|
+
state: string;
|
|
1300
|
+
width: number;
|
|
1301
|
+
height: number;
|
|
1302
|
+
x: number;
|
|
1303
|
+
y: number;
|
|
1304
|
+
};
|
|
1305
|
+
frames(): PageSync[];
|
|
1306
|
+
frame(nameOrUrl: string): PageSync | null;
|
|
1307
|
+
mainFrame(): PageSync;
|
|
1308
|
+
a11yTree(options?: {
|
|
1309
|
+
everything?: boolean;
|
|
1310
|
+
root?: string;
|
|
1311
|
+
}): A11yNode;
|
|
1312
|
+
route(pattern: string, action: 'continue' | 'abort' | {
|
|
1313
|
+
status?: number;
|
|
1314
|
+
body?: string;
|
|
1315
|
+
headers?: Record<string, string>;
|
|
1316
|
+
} | ((route: RouteSync) => void)): void;
|
|
1317
|
+
unroute(pattern: string): void;
|
|
1318
|
+
setHeaders(headers: Record<string, string>): void;
|
|
1319
|
+
onDialog(action: 'accept' | 'dismiss' | ((dialog: DialogSync) => void)): void;
|
|
1320
|
+
onConsole(mode: 'collect'): void;
|
|
1321
|
+
consoleMessages(): {
|
|
1322
|
+
type: string;
|
|
1323
|
+
text: string;
|
|
1324
|
+
}[];
|
|
1325
|
+
onError(mode: 'collect'): void;
|
|
1326
|
+
errors(): {
|
|
1327
|
+
message: string;
|
|
1328
|
+
}[];
|
|
1329
|
+
onRequest(fn: (req: RequestData) => void): void;
|
|
1330
|
+
onResponse(fn: (resp: ResponseData) => void): void;
|
|
1331
|
+
onDownload(fn: (dl: DownloadData) => void): void;
|
|
1332
|
+
onWebSocket(fn: (ws: WebSocketInfoSync) => void): void;
|
|
1333
|
+
removeAllListeners(event?: 'request' | 'response' | 'dialog' | 'console' | 'error' | 'download' | 'websocket'): void;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
declare const customInspect: unique symbol;
|
|
1337
|
+
declare class BrowserSync {
|
|
1338
|
+
/** @internal */
|
|
1339
|
+
readonly _bridge: SyncBridge;
|
|
1340
|
+
private _nextHandlerId;
|
|
1341
|
+
private _pageHandlerId?;
|
|
1342
|
+
private _popupHandlerId?;
|
|
1343
|
+
constructor(bridge: SyncBridge);
|
|
1344
|
+
[customInspect](): string;
|
|
1345
|
+
page(): PageSync;
|
|
1346
|
+
newPage(): PageSync;
|
|
1347
|
+
pages(): PageSync[];
|
|
1348
|
+
newContext(): BrowserContextSync;
|
|
1349
|
+
waitForPage(options?: {
|
|
1350
|
+
timeout?: number;
|
|
1351
|
+
}): PageSync;
|
|
1352
|
+
waitForPopup(options?: {
|
|
1353
|
+
timeout?: number;
|
|
1354
|
+
}): PageSync;
|
|
1355
|
+
onPage(callback: (page: PageSync) => void): void;
|
|
1356
|
+
onPopup(callback: (page: PageSync) => void): void;
|
|
1357
|
+
removeAllListeners(event?: 'page' | 'popup'): void;
|
|
1358
|
+
stop(): void;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Custom error types for the Vibium client library.
|
|
1363
|
+
*/
|
|
1364
|
+
/**
|
|
1365
|
+
* ConnectionError is thrown when connecting to the browser fails.
|
|
1366
|
+
*/
|
|
1367
|
+
declare class ConnectionError extends Error {
|
|
1368
|
+
url: string;
|
|
1369
|
+
cause?: Error | undefined;
|
|
1370
|
+
constructor(url: string, cause?: Error | undefined);
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* TimeoutError is thrown when a wait operation times out.
|
|
1374
|
+
*/
|
|
1375
|
+
declare class TimeoutError extends Error {
|
|
1376
|
+
selector: string;
|
|
1377
|
+
timeout: number;
|
|
1378
|
+
reason?: string | undefined;
|
|
1379
|
+
constructor(selector: string, timeout: number, reason?: string | undefined);
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* ElementNotFoundError is thrown when a selector matches no elements.
|
|
1383
|
+
*/
|
|
1384
|
+
declare class ElementNotFoundError extends Error {
|
|
1385
|
+
selector: string;
|
|
1386
|
+
constructor(selector: string);
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* BrowserCrashedError is thrown when the browser process dies unexpectedly.
|
|
1390
|
+
*/
|
|
1391
|
+
declare class BrowserCrashedError extends Error {
|
|
1392
|
+
exitCode: number;
|
|
1393
|
+
output?: string | undefined;
|
|
1394
|
+
constructor(exitCode: number, output?: string | undefined);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
export { type A11yNode, type ActionOptions, type BoundingBox, Browser, BrowserContext, BrowserContextSync, BrowserCrashedError, BrowserSync, Clock, type ClockInstallOptions$1 as ClockInstallOptions, ClockSync, ConnectionError, ConsoleMessage, type Cookie, Dialog, Download, Element, type ElementInfo, ElementNotFoundError, ElementSync, type FindOptions, type FluentElement, Keyboard, KeyboardSync, Mouse, MouseSync, type OriginState, Page, PageSync, Recording, type RecordingStartOptions, type RecordingStopOptions, RecordingSync, Request, Response, Route, type ScreenshotOptions, type SelectorOptions, type SetCookieParam, type StartOptions, type StorageState, TimeoutError, Touch, TouchSync, WebSocketInfo, browser, fluent };
|