@olib-ai/owl-browser-sdk 2.0.4 → 2.0.6
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 +107 -0
- package/dist/extraction/content-cleaner.d.ts +40 -0
- package/dist/extraction/content-cleaner.d.ts.map +1 -0
- package/dist/extraction/content-cleaner.js +393 -0
- package/dist/extraction/content-cleaner.js.map +1 -0
- package/dist/extraction/extractor.d.ts +139 -0
- package/dist/extraction/extractor.d.ts.map +1 -0
- package/dist/extraction/extractor.js +212 -0
- package/dist/extraction/extractor.js.map +1 -0
- package/dist/extraction/html-processor.d.ts +75 -0
- package/dist/extraction/html-processor.d.ts.map +1 -0
- package/dist/extraction/html-processor.js +192 -0
- package/dist/extraction/html-processor.js.map +1 -0
- package/dist/extraction/index.d.ts +14 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +19 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/extraction/list-extractor.d.ts +24 -0
- package/dist/extraction/list-extractor.d.ts.map +1 -0
- package/dist/extraction/list-extractor.js +303 -0
- package/dist/extraction/list-extractor.js.map +1 -0
- package/dist/extraction/meta-extractor.d.ts +40 -0
- package/dist/extraction/meta-extractor.d.ts.map +1 -0
- package/dist/extraction/meta-extractor.js +216 -0
- package/dist/extraction/meta-extractor.js.map +1 -0
- package/dist/extraction/pagination.d.ts +29 -0
- package/dist/extraction/pagination.d.ts.map +1 -0
- package/dist/extraction/pagination.js +323 -0
- package/dist/extraction/pagination.js.map +1 -0
- package/dist/extraction/pattern-detector.d.ts +16 -0
- package/dist/extraction/pattern-detector.d.ts.map +1 -0
- package/dist/extraction/pattern-detector.js +390 -0
- package/dist/extraction/pattern-detector.js.map +1 -0
- package/dist/extraction/scrape-session.d.ts +23 -0
- package/dist/extraction/scrape-session.d.ts.map +1 -0
- package/dist/extraction/scrape-session.js +192 -0
- package/dist/extraction/scrape-session.js.map +1 -0
- package/dist/extraction/selector-engine.d.ts +23 -0
- package/dist/extraction/selector-engine.d.ts.map +1 -0
- package/dist/extraction/selector-engine.js +127 -0
- package/dist/extraction/selector-engine.js.map +1 -0
- package/dist/extraction/table-extractor.d.ts +29 -0
- package/dist/extraction/table-extractor.d.ts.map +1 -0
- package/dist/extraction/table-extractor.js +282 -0
- package/dist/extraction/table-extractor.js.map +1 -0
- package/dist/extraction/transforms.d.ts +47 -0
- package/dist/extraction/transforms.d.ts.map +1 -0
- package/dist/extraction/transforms.js +277 -0
- package/dist/extraction/transforms.js.map +1 -0
- package/dist/extraction/types.d.ts +199 -0
- package/dist/extraction/types.d.ts.map +1 -0
- package/dist/extraction/types.js +5 -0
- package/dist/extraction/types.js.map +1 -0
- package/dist/flow/executor.js +1 -1
- package/dist/flow/executor.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/playwright/browser-type.d.ts +101 -0
- package/dist/playwright/browser-type.d.ts.map +1 -0
- package/dist/playwright/browser-type.js +134 -0
- package/dist/playwright/browser-type.js.map +1 -0
- package/dist/playwright/browser.d.ts +98 -0
- package/dist/playwright/browser.d.ts.map +1 -0
- package/dist/playwright/browser.js +229 -0
- package/dist/playwright/browser.js.map +1 -0
- package/dist/playwright/context.d.ts +211 -0
- package/dist/playwright/context.d.ts.map +1 -0
- package/dist/playwright/context.js +466 -0
- package/dist/playwright/context.js.map +1 -0
- package/dist/playwright/extractor.d.ts +108 -0
- package/dist/playwright/extractor.d.ts.map +1 -0
- package/dist/playwright/extractor.js +404 -0
- package/dist/playwright/extractor.js.map +1 -0
- package/dist/playwright/frame.d.ts +147 -0
- package/dist/playwright/frame.d.ts.map +1 -0
- package/dist/playwright/frame.js +492 -0
- package/dist/playwright/frame.js.map +1 -0
- package/dist/playwright/index.d.ts +163 -0
- package/dist/playwright/index.d.ts.map +1 -0
- package/dist/playwright/index.js +313 -0
- package/dist/playwright/index.js.map +1 -0
- package/dist/playwright/keyboard.d.ts +74 -0
- package/dist/playwright/keyboard.d.ts.map +1 -0
- package/dist/playwright/keyboard.js +187 -0
- package/dist/playwright/keyboard.js.map +1 -0
- package/dist/playwright/locator.d.ts +237 -0
- package/dist/playwright/locator.d.ts.map +1 -0
- package/dist/playwright/locator.js +646 -0
- package/dist/playwright/locator.js.map +1 -0
- package/dist/playwright/mouse.d.ts +82 -0
- package/dist/playwright/mouse.d.ts.map +1 -0
- package/dist/playwright/mouse.js +137 -0
- package/dist/playwright/mouse.js.map +1 -0
- package/dist/playwright/page-helpers.d.ts +261 -0
- package/dist/playwright/page-helpers.d.ts.map +1 -0
- package/dist/playwright/page-helpers.js +423 -0
- package/dist/playwright/page-helpers.js.map +1 -0
- package/dist/playwright/page.d.ts +566 -0
- package/dist/playwright/page.d.ts.map +1 -0
- package/dist/playwright/page.js +1476 -0
- package/dist/playwright/page.js.map +1 -0
- package/dist/playwright/response.d.ts +100 -0
- package/dist/playwright/response.d.ts.map +1 -0
- package/dist/playwright/response.js +194 -0
- package/dist/playwright/response.js.map +1 -0
- package/dist/playwright/types.d.ts +354 -0
- package/dist/playwright/types.d.ts.map +1 -0
- package/dist/playwright/types.js +8 -0
- package/dist/playwright/types.js.map +1 -0
- package/openapi.json +343 -36
- package/package.json +10 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright-compatible Mouse class for Owl Browser.
|
|
3
|
+
*
|
|
4
|
+
* Maps Playwright mouse operations to Owl Browser tool executions.
|
|
5
|
+
* Coordinates are in CSS pixels relative to the viewport origin.
|
|
6
|
+
*/
|
|
7
|
+
import type { OwlBrowser } from '../client.js';
|
|
8
|
+
import type { MouseButton } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Mouse provides methods for simulating mouse input at specific coordinates.
|
|
11
|
+
*
|
|
12
|
+
* Mirrors the Playwright Mouse API. Use Page methods (page.click, page.hover)
|
|
13
|
+
* for selector-based interactions; use Mouse for coordinate-based control.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Mouse {
|
|
16
|
+
private readonly _client;
|
|
17
|
+
private readonly _contextId;
|
|
18
|
+
private _x;
|
|
19
|
+
private _y;
|
|
20
|
+
constructor(client: OwlBrowser, contextId: string);
|
|
21
|
+
/**
|
|
22
|
+
* Click at the given coordinates.
|
|
23
|
+
*
|
|
24
|
+
* @param x - X coordinate in CSS pixels
|
|
25
|
+
* @param y - Y coordinate in CSS pixels
|
|
26
|
+
* @param options - Click options (button, clickCount, delay)
|
|
27
|
+
*/
|
|
28
|
+
click(x: number, y: number, options?: {
|
|
29
|
+
button?: MouseButton;
|
|
30
|
+
clickCount?: number;
|
|
31
|
+
delay?: number;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Double-click at the given coordinates.
|
|
35
|
+
*
|
|
36
|
+
* @param x - X coordinate in CSS pixels
|
|
37
|
+
* @param y - Y coordinate in CSS pixels
|
|
38
|
+
* @param options - Click options
|
|
39
|
+
*/
|
|
40
|
+
dblclick(x: number, y: number, options?: {
|
|
41
|
+
button?: MouseButton;
|
|
42
|
+
delay?: number;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Move the mouse to the given coordinates.
|
|
46
|
+
*
|
|
47
|
+
* Uses bezier curves with human-like movement for realism.
|
|
48
|
+
*
|
|
49
|
+
* @param x - X coordinate in CSS pixels
|
|
50
|
+
* @param y - Y coordinate in CSS pixels
|
|
51
|
+
* @param options - Movement options (steps for smooth animation)
|
|
52
|
+
*/
|
|
53
|
+
move(x: number, y: number, options?: {
|
|
54
|
+
steps?: number;
|
|
55
|
+
}): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Press the mouse button at the current position.
|
|
58
|
+
*
|
|
59
|
+
* @param options - Button to press
|
|
60
|
+
*/
|
|
61
|
+
down(options?: {
|
|
62
|
+
button?: MouseButton;
|
|
63
|
+
clickCount?: number;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Release the mouse button at the current position.
|
|
67
|
+
*
|
|
68
|
+
* @param options - Button to release
|
|
69
|
+
*/
|
|
70
|
+
up(options?: {
|
|
71
|
+
button?: MouseButton;
|
|
72
|
+
clickCount?: number;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Scroll the mouse wheel.
|
|
76
|
+
*
|
|
77
|
+
* @param deltaX - Horizontal scroll amount in pixels
|
|
78
|
+
* @param deltaY - Vertical scroll amount in pixels
|
|
79
|
+
*/
|
|
80
|
+
wheel(deltaX: number, deltaY: number): Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=mouse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouse.d.ts","sourceRoot":"","sources":["../../src/playwright/mouse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;GAKG;AACH,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,EAAE,CAAK;IACf,OAAO,CAAC,EAAE,CAAK;gBAEH,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM;IAKjD;;;;;;OAMG;IACG,KAAK,CACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACtE,OAAO,CAAC,IAAI,CAAC;IA2BhB;;;;;;OAMG;IACG,QAAQ,CACZ,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACjD,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;;;;OAQG;IACG,IAAI,CACR,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;OAIG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAalF;;;;OAIG;IACG,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhF;;;;;OAKG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAU3D"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright-compatible Mouse class for Owl Browser.
|
|
3
|
+
*
|
|
4
|
+
* Maps Playwright mouse operations to Owl Browser tool executions.
|
|
5
|
+
* Coordinates are in CSS pixels relative to the viewport origin.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Mouse provides methods for simulating mouse input at specific coordinates.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors the Playwright Mouse API. Use Page methods (page.click, page.hover)
|
|
11
|
+
* for selector-based interactions; use Mouse for coordinate-based control.
|
|
12
|
+
*/
|
|
13
|
+
export class Mouse {
|
|
14
|
+
_client;
|
|
15
|
+
_contextId;
|
|
16
|
+
_x = 0;
|
|
17
|
+
_y = 0;
|
|
18
|
+
constructor(client, contextId) {
|
|
19
|
+
this._client = client;
|
|
20
|
+
this._contextId = contextId;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Click at the given coordinates.
|
|
24
|
+
*
|
|
25
|
+
* @param x - X coordinate in CSS pixels
|
|
26
|
+
* @param y - Y coordinate in CSS pixels
|
|
27
|
+
* @param options - Click options (button, clickCount, delay)
|
|
28
|
+
*/
|
|
29
|
+
async click(x, y, options) {
|
|
30
|
+
this._x = x;
|
|
31
|
+
this._y = y;
|
|
32
|
+
const selector = `${Math.round(x)}x${Math.round(y)}`;
|
|
33
|
+
if (options?.button === 'right') {
|
|
34
|
+
await this._client.execute('browser_right_click', {
|
|
35
|
+
context_id: this._contextId,
|
|
36
|
+
selector,
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (options?.clickCount === 2) {
|
|
41
|
+
await this._client.execute('browser_double_click', {
|
|
42
|
+
context_id: this._contextId,
|
|
43
|
+
selector,
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
await this._client.execute('browser_click', {
|
|
48
|
+
context_id: this._contextId,
|
|
49
|
+
selector,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Double-click at the given coordinates.
|
|
54
|
+
*
|
|
55
|
+
* @param x - X coordinate in CSS pixels
|
|
56
|
+
* @param y - Y coordinate in CSS pixels
|
|
57
|
+
* @param options - Click options
|
|
58
|
+
*/
|
|
59
|
+
async dblclick(x, y, options) {
|
|
60
|
+
void options;
|
|
61
|
+
this._x = x;
|
|
62
|
+
this._y = y;
|
|
63
|
+
const selector = `${Math.round(x)}x${Math.round(y)}`;
|
|
64
|
+
await this._client.execute('browser_double_click', {
|
|
65
|
+
context_id: this._contextId,
|
|
66
|
+
selector,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Move the mouse to the given coordinates.
|
|
71
|
+
*
|
|
72
|
+
* Uses bezier curves with human-like movement for realism.
|
|
73
|
+
*
|
|
74
|
+
* @param x - X coordinate in CSS pixels
|
|
75
|
+
* @param y - Y coordinate in CSS pixels
|
|
76
|
+
* @param options - Movement options (steps for smooth animation)
|
|
77
|
+
*/
|
|
78
|
+
async move(x, y, options) {
|
|
79
|
+
const params = {
|
|
80
|
+
context_id: this._contextId,
|
|
81
|
+
start_x: Math.round(this._x),
|
|
82
|
+
start_y: Math.round(this._y),
|
|
83
|
+
end_x: Math.round(x),
|
|
84
|
+
end_y: Math.round(y),
|
|
85
|
+
};
|
|
86
|
+
if (options?.steps !== undefined) {
|
|
87
|
+
params['steps'] = options.steps;
|
|
88
|
+
}
|
|
89
|
+
await this._client.execute('browser_mouse_move', params);
|
|
90
|
+
this._x = x;
|
|
91
|
+
this._y = y;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Press the mouse button at the current position.
|
|
95
|
+
*
|
|
96
|
+
* @param options - Button to press
|
|
97
|
+
*/
|
|
98
|
+
async down(options) {
|
|
99
|
+
void options;
|
|
100
|
+
// Owl Browser does not have separate mouse down/up.
|
|
101
|
+
// Moving to current position keeps state consistent.
|
|
102
|
+
await this._client.execute('browser_mouse_move', {
|
|
103
|
+
context_id: this._contextId,
|
|
104
|
+
start_x: Math.round(this._x),
|
|
105
|
+
start_y: Math.round(this._y),
|
|
106
|
+
end_x: Math.round(this._x),
|
|
107
|
+
end_y: Math.round(this._y),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Release the mouse button at the current position.
|
|
112
|
+
*
|
|
113
|
+
* @param options - Button to release
|
|
114
|
+
*/
|
|
115
|
+
async up(options) {
|
|
116
|
+
void options;
|
|
117
|
+
// Owl Browser handles mouse release automatically.
|
|
118
|
+
// This method exists for API compatibility.
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Scroll the mouse wheel.
|
|
122
|
+
*
|
|
123
|
+
* @param deltaX - Horizontal scroll amount in pixels
|
|
124
|
+
* @param deltaY - Vertical scroll amount in pixels
|
|
125
|
+
*/
|
|
126
|
+
async wheel(deltaX, deltaY) {
|
|
127
|
+
const params = {
|
|
128
|
+
context_id: this._contextId,
|
|
129
|
+
y: Math.round(deltaY),
|
|
130
|
+
};
|
|
131
|
+
if (deltaX !== 0) {
|
|
132
|
+
params['x'] = Math.round(deltaX);
|
|
133
|
+
}
|
|
134
|
+
await this._client.execute('browser_scroll_by', params);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=mouse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouse.js","sourceRoot":"","sources":["../../src/playwright/mouse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;GAKG;AACH,MAAM,OAAO,KAAK;IACC,OAAO,CAAa;IACpB,UAAU,CAAS;IAC5B,EAAE,GAAG,CAAC,CAAC;IACP,EAAE,GAAG,CAAC,CAAC;IAEf,YAAY,MAAkB,EAAE,SAAiB;QAC/C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CACT,CAAS,EACT,CAAS,EACT,OAAuE;QAEvE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAErD,IAAI,OAAO,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;YAChC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE;gBAChD,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,QAAQ;aACT,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,IAAI,OAAO,EAAE,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,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper classes for the Playwright Page API.
|
|
3
|
+
*
|
|
4
|
+
* Contains Route, Dialog, ConsoleMessage, Download, and Video classes
|
|
5
|
+
* that support the Page event and interception APIs. Split from page.ts
|
|
6
|
+
* to keep each file under 1000 lines.
|
|
7
|
+
*/
|
|
8
|
+
import type { OwlBrowser } from '../client.js';
|
|
9
|
+
import type { RouteFulfillOptions } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Route represents an intercepted network request.
|
|
12
|
+
*
|
|
13
|
+
* Created by page.route() or context.route(). Provides methods to
|
|
14
|
+
* fulfill, abort, or continue the intercepted request.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* await page.route('**\/api/**', async route => {
|
|
19
|
+
* await route.fulfill({ status: 200, body: '{"mock": true}' });
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class Route {
|
|
24
|
+
private readonly _client;
|
|
25
|
+
private readonly _contextId;
|
|
26
|
+
private readonly _ruleId;
|
|
27
|
+
private readonly _urlPattern;
|
|
28
|
+
private readonly _request;
|
|
29
|
+
constructor(client: OwlBrowser, contextId: string, ruleId: string, urlPattern: string);
|
|
30
|
+
/** The associated Request object. */
|
|
31
|
+
request(): RouteRequest;
|
|
32
|
+
/**
|
|
33
|
+
* Fulfill the route with a custom response.
|
|
34
|
+
*
|
|
35
|
+
* Replaces the actual server response with the provided data.
|
|
36
|
+
*
|
|
37
|
+
* @param options - Response data (status, headers, body, contentType)
|
|
38
|
+
*/
|
|
39
|
+
fulfill(options?: RouteFulfillOptions): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Abort the route, preventing the request from completing.
|
|
42
|
+
*
|
|
43
|
+
* @param errorCode - Optional error code (default: 'failed')
|
|
44
|
+
*/
|
|
45
|
+
abort(errorCode?: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Continue the route without modification.
|
|
48
|
+
*
|
|
49
|
+
* Allows the request to proceed to the server normally.
|
|
50
|
+
*
|
|
51
|
+
* @param options - Optional overrides (url, headers, postData)
|
|
52
|
+
*/
|
|
53
|
+
continue(options?: {
|
|
54
|
+
url?: string;
|
|
55
|
+
headers?: Record<string, string>;
|
|
56
|
+
postData?: string;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Fallback to the next route handler.
|
|
60
|
+
*
|
|
61
|
+
* In Owl Browser, this is equivalent to continue().
|
|
62
|
+
*/
|
|
63
|
+
fallback(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Minimal Request object for Route.request().
|
|
67
|
+
*/
|
|
68
|
+
export declare class RouteRequest {
|
|
69
|
+
private readonly _url;
|
|
70
|
+
constructor(url: string);
|
|
71
|
+
/** Request URL pattern. */
|
|
72
|
+
url(): string;
|
|
73
|
+
/** HTTP method. */
|
|
74
|
+
method(): string;
|
|
75
|
+
/** Request resource type. */
|
|
76
|
+
resourceType(): string;
|
|
77
|
+
/** Request headers. */
|
|
78
|
+
headers(): Record<string, string>;
|
|
79
|
+
/** POST body data, if any. */
|
|
80
|
+
postData(): string | null;
|
|
81
|
+
/** Whether this is a navigation request. */
|
|
82
|
+
isNavigationRequest(): boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Dialog represents a JavaScript dialog (alert, confirm, prompt, beforeunload).
|
|
86
|
+
*
|
|
87
|
+
* Created when a dialog event is intercepted. Provides methods to
|
|
88
|
+
* accept or dismiss the dialog programmatically.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* page.on('dialog', async dialog => {
|
|
93
|
+
* console.log(dialog.message());
|
|
94
|
+
* await dialog.accept('input text');
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare class Dialog {
|
|
99
|
+
private readonly _client;
|
|
100
|
+
private readonly _type;
|
|
101
|
+
private readonly _message;
|
|
102
|
+
private readonly _defaultValue;
|
|
103
|
+
private readonly _dialogId;
|
|
104
|
+
constructor(client: OwlBrowser, type: string, message: string, defaultValue: string, dialogId: string);
|
|
105
|
+
/** Dialog type: 'alert', 'confirm', 'prompt', or 'beforeunload'. */
|
|
106
|
+
type(): string;
|
|
107
|
+
/** Dialog message text. */
|
|
108
|
+
message(): string;
|
|
109
|
+
/** Default value for prompt dialogs. */
|
|
110
|
+
defaultValue(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Accept the dialog (click OK / Yes).
|
|
113
|
+
*
|
|
114
|
+
* @param promptText - Text to enter for prompt dialogs
|
|
115
|
+
*/
|
|
116
|
+
accept(promptText?: string): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Dismiss the dialog (click Cancel / No).
|
|
119
|
+
*/
|
|
120
|
+
dismiss(): Promise<void>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* ConsoleMessage represents a browser console message.
|
|
124
|
+
*
|
|
125
|
+
* Created from browser_get_console_log entries.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* page.on('console', msg => {
|
|
130
|
+
* console.log(`[${msg.type()}] ${msg.text()}`);
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare class ConsoleMessage {
|
|
135
|
+
private readonly _type;
|
|
136
|
+
private readonly _text;
|
|
137
|
+
private readonly _location;
|
|
138
|
+
constructor(type: string, text: string, url?: string, line?: number, column?: number);
|
|
139
|
+
/** Console message type: 'log', 'warn', 'error', 'info', 'debug'. */
|
|
140
|
+
type(): string;
|
|
141
|
+
/** Console message text content. */
|
|
142
|
+
text(): string;
|
|
143
|
+
/** Source location of the console call. */
|
|
144
|
+
location(): {
|
|
145
|
+
url: string;
|
|
146
|
+
lineNumber: number;
|
|
147
|
+
columnNumber: number;
|
|
148
|
+
};
|
|
149
|
+
/** Arguments passed to the console call (returns text as single element). */
|
|
150
|
+
args(): string[];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Download represents a file download initiated by the browser.
|
|
154
|
+
*
|
|
155
|
+
* Provides methods to monitor download progress, wait for completion,
|
|
156
|
+
* and access the downloaded file.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const [download] = await Promise.all([
|
|
161
|
+
* page.waitForEvent('download'),
|
|
162
|
+
* page.click('#download-btn'),
|
|
163
|
+
* ]);
|
|
164
|
+
* const path = await download.path();
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export declare class Download {
|
|
168
|
+
private readonly _client;
|
|
169
|
+
private readonly _contextId;
|
|
170
|
+
private readonly _downloadId;
|
|
171
|
+
private readonly _url;
|
|
172
|
+
private readonly _suggestedFilename;
|
|
173
|
+
constructor(client: OwlBrowser, contextId: string, downloadId: string, url: string, suggestedFilename: string);
|
|
174
|
+
/** Download URL. */
|
|
175
|
+
url(): string;
|
|
176
|
+
/** Suggested filename for the download. */
|
|
177
|
+
suggestedFilename(): string;
|
|
178
|
+
/**
|
|
179
|
+
* Wait for the download to complete and return the file path.
|
|
180
|
+
*
|
|
181
|
+
* @returns Absolute path to the downloaded file, or null on failure
|
|
182
|
+
*/
|
|
183
|
+
path(): Promise<string | null>;
|
|
184
|
+
/**
|
|
185
|
+
* Save the download to a specific path.
|
|
186
|
+
*
|
|
187
|
+
* @param path - Target file path
|
|
188
|
+
*/
|
|
189
|
+
saveAs(path: string): Promise<void>;
|
|
190
|
+
/**
|
|
191
|
+
* Cancel the download.
|
|
192
|
+
*/
|
|
193
|
+
cancel(): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Delete the downloaded file.
|
|
196
|
+
*/
|
|
197
|
+
delete(): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Wait for the download to finish.
|
|
200
|
+
*
|
|
201
|
+
* @returns null on success, Error on failure
|
|
202
|
+
*/
|
|
203
|
+
failure(): Promise<string | null>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Video represents a video recording of a browser context.
|
|
207
|
+
*
|
|
208
|
+
* Created when context is configured with recordVideo option.
|
|
209
|
+
* Provides access to the recording path after the recording stops.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const context = await browser.newContext({ recordVideo: { dir: '/tmp/videos' } });
|
|
214
|
+
* const page = await context.newPage();
|
|
215
|
+
* // ... perform actions ...
|
|
216
|
+
* const videoPath = await page.video()?.path();
|
|
217
|
+
* await context.close();
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export declare class Video {
|
|
221
|
+
private readonly _client;
|
|
222
|
+
private readonly _contextId;
|
|
223
|
+
private _path;
|
|
224
|
+
constructor(client: OwlBrowser, contextId: string);
|
|
225
|
+
/**
|
|
226
|
+
* Get the path to the video recording.
|
|
227
|
+
*
|
|
228
|
+
* The path becomes available after the recording is stopped.
|
|
229
|
+
*
|
|
230
|
+
* @returns Absolute path to the video file
|
|
231
|
+
*/
|
|
232
|
+
path(): Promise<string>;
|
|
233
|
+
/**
|
|
234
|
+
* Save the video to a specific path.
|
|
235
|
+
*
|
|
236
|
+
* @param path - Target file path
|
|
237
|
+
*/
|
|
238
|
+
saveAs(path: string): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Delete the video recording file.
|
|
241
|
+
*/
|
|
242
|
+
delete(): Promise<void>;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Supported page event names for page.on() and page.once().
|
|
246
|
+
*/
|
|
247
|
+
export type PageEventName = 'close' | 'console' | 'dialog' | 'download' | 'load' | 'domcontentloaded' | 'pageerror' | 'popup' | 'request' | 'requestfinished' | 'requestfailed' | 'response';
|
|
248
|
+
/**
|
|
249
|
+
* Event handler function type.
|
|
250
|
+
*/
|
|
251
|
+
export type EventHandler = (...args: unknown[]) => void | Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* Registered route entry for tracking active interceptions.
|
|
254
|
+
*/
|
|
255
|
+
export interface RouteEntry {
|
|
256
|
+
readonly urlPattern: string;
|
|
257
|
+
readonly ruleId: string;
|
|
258
|
+
readonly handler: (route: Route) => void | Promise<void>;
|
|
259
|
+
remaining: number | null;
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=page-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-helpers.d.ts","sourceRoot":"","sources":["../../src/playwright/page-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAItD;;;;;;;;;;;;GAYG;AACH,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;gBAGtC,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM;IASpB,qCAAqC;IACrC,OAAO,IAAI,YAAY;IAIvB;;;;;;OAMG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC3D;;;;OAIG;IACG,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB9C;;;;;;OAMG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE;QACvB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,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