browserclaw 0.10.6 → 0.11.1
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 +132 -60
- package/dist/index.cjs +550 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -8
- package/dist/index.d.ts +113 -8
- package/dist/index.js +550 -58
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -77,6 +77,7 @@ type BatchAction = {
|
|
|
77
77
|
url?: string;
|
|
78
78
|
loadState?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
79
79
|
fn?: string;
|
|
80
|
+
arg?: unknown;
|
|
80
81
|
targetId?: string;
|
|
81
82
|
timeoutMs?: number;
|
|
82
83
|
} | {
|
|
@@ -168,6 +169,8 @@ interface ChromeExecutable {
|
|
|
168
169
|
}
|
|
169
170
|
/** Options for launching a new browser instance. */
|
|
170
171
|
interface LaunchOptions {
|
|
172
|
+
/** URL to navigate to after launch. If omitted, the initial tab stays on `about:blank`. */
|
|
173
|
+
url?: string;
|
|
171
174
|
/** Run in headless mode (no visible window). Default: `false` */
|
|
172
175
|
headless?: boolean;
|
|
173
176
|
/** Path to a specific browser executable. Auto-detected if omitted. */
|
|
@@ -184,6 +187,8 @@ interface LaunchOptions {
|
|
|
184
187
|
profileColor?: string;
|
|
185
188
|
/** Additional Chrome command-line arguments (e.g. `['--start-maximized']`). */
|
|
186
189
|
chromeArgs?: string[];
|
|
190
|
+
/** Ignore HTTPS certificate errors (e.g. expired local dev certs). Default: `false` */
|
|
191
|
+
ignoreHTTPSErrors?: boolean;
|
|
187
192
|
/**
|
|
188
193
|
* SSRF policy controlling which URLs navigation is allowed to reach.
|
|
189
194
|
* Defaults to trusted-network mode (private/internal addresses allowed).
|
|
@@ -249,6 +254,10 @@ interface RoleRefInfo {
|
|
|
249
254
|
name?: string;
|
|
250
255
|
/** Disambiguation index when multiple elements share the same role + name */
|
|
251
256
|
nth?: number;
|
|
257
|
+
/** Whether the element is disabled (from `[disabled]` or `aria-disabled`) */
|
|
258
|
+
disabled?: boolean;
|
|
259
|
+
/** Whether a checkbox/radio/switch is checked */
|
|
260
|
+
checked?: boolean | 'mixed';
|
|
252
261
|
}
|
|
253
262
|
/** Map of ref IDs (e.g. `'e1'`, `'e2'`) to their element information. */
|
|
254
263
|
type RoleRefs = Record<string, RoleRefInfo>;
|
|
@@ -375,6 +384,8 @@ interface ClickOptions {
|
|
|
375
384
|
delayMs?: number;
|
|
376
385
|
/** Timeout in milliseconds. Default: `8000` */
|
|
377
386
|
timeoutMs?: number;
|
|
387
|
+
/** Force click even if element is hidden or covered. Dispatches the event regardless of visibility. */
|
|
388
|
+
force?: boolean;
|
|
378
389
|
}
|
|
379
390
|
/** Options for type actions. */
|
|
380
391
|
interface TypeOptions {
|
|
@@ -402,8 +413,10 @@ interface WaitOptions {
|
|
|
402
413
|
url?: string;
|
|
403
414
|
/** Wait for a specific page load state */
|
|
404
415
|
loadState?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
405
|
-
/** Wait until a JavaScript function returns truthy (evaluated in browser context) */
|
|
406
|
-
fn?: string;
|
|
416
|
+
/** Wait until a JavaScript function returns truthy (evaluated in browser context). Accepts a string or a serializable function. */
|
|
417
|
+
fn?: string | ((arg?: unknown) => unknown);
|
|
418
|
+
/** Serializable argument passed to `fn` in the browser context. Use an array or object to pass multiple values. */
|
|
419
|
+
arg?: unknown;
|
|
407
420
|
/** Timeout for each condition in milliseconds. Default: `20000` */
|
|
408
421
|
timeoutMs?: number;
|
|
409
422
|
}
|
|
@@ -532,6 +545,23 @@ interface DialogEvent {
|
|
|
532
545
|
}
|
|
533
546
|
/** Callback for persistent dialog handling. */
|
|
534
547
|
type DialogHandler = (event: DialogEvent) => void | Promise<void>;
|
|
548
|
+
/** Result of waiting for a network request to complete. */
|
|
549
|
+
interface RequestResult {
|
|
550
|
+
/** The final request URL */
|
|
551
|
+
url: string;
|
|
552
|
+
/** HTTP method (e.g. `'GET'`, `'POST'`) */
|
|
553
|
+
method: string;
|
|
554
|
+
/** Request body (for POST/PUT/PATCH requests) */
|
|
555
|
+
postData?: string;
|
|
556
|
+
/** HTTP response status code */
|
|
557
|
+
status: number;
|
|
558
|
+
/** Whether the response status was 2xx */
|
|
559
|
+
ok: boolean;
|
|
560
|
+
/** Response body text */
|
|
561
|
+
responseBody?: string;
|
|
562
|
+
/** Whether the response body was truncated due to maxChars */
|
|
563
|
+
truncated?: boolean;
|
|
564
|
+
}
|
|
535
565
|
/** Result of intercepting a response body. */
|
|
536
566
|
interface ResponseBodyResult {
|
|
537
567
|
/** The response URL */
|
|
@@ -717,6 +747,26 @@ declare class CrawlPage {
|
|
|
717
747
|
clickCount?: number;
|
|
718
748
|
delayMs?: number;
|
|
719
749
|
}): Promise<void>;
|
|
750
|
+
/**
|
|
751
|
+
* Press and hold at page coordinates using raw CDP events.
|
|
752
|
+
*
|
|
753
|
+
* Bypasses Playwright's automation layer by dispatching CDP
|
|
754
|
+
* `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
|
|
755
|
+
* that detect automated clicks.
|
|
756
|
+
*
|
|
757
|
+
* @param x - X coordinate in CSS pixels
|
|
758
|
+
* @param y - Y coordinate in CSS pixels
|
|
759
|
+
* @param opts - Options (delay: ms before press, holdMs: hold duration)
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* ```ts
|
|
763
|
+
* await page.pressAndHold(400, 300, { delay: 150, holdMs: 5000 });
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
pressAndHold(x: number, y: number, opts?: {
|
|
767
|
+
delay?: number;
|
|
768
|
+
holdMs?: number;
|
|
769
|
+
}): Promise<void>;
|
|
720
770
|
/**
|
|
721
771
|
* Click an element by its visible text content (no snapshot/ref needed).
|
|
722
772
|
*
|
|
@@ -754,6 +804,7 @@ declare class CrawlPage {
|
|
|
754
804
|
* ```
|
|
755
805
|
*/
|
|
756
806
|
clickByRole(role: string, name?: string, opts?: {
|
|
807
|
+
index?: number;
|
|
757
808
|
button?: 'left' | 'right' | 'middle';
|
|
758
809
|
modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[];
|
|
759
810
|
timeoutMs?: number;
|
|
@@ -1136,6 +1187,30 @@ declare class CrawlPage {
|
|
|
1136
1187
|
timeoutMs?: number;
|
|
1137
1188
|
maxChars?: number;
|
|
1138
1189
|
}): Promise<ResponseBodyResult>;
|
|
1190
|
+
/**
|
|
1191
|
+
* Wait for a network request matching a URL pattern and return request + response details.
|
|
1192
|
+
*
|
|
1193
|
+
* Unlike `networkRequests()` which only captures metadata, this method captures
|
|
1194
|
+
* the full request body (POST data) and response body.
|
|
1195
|
+
*
|
|
1196
|
+
* @param url - URL string or pattern to match (supports `*` wildcards and substring matching)
|
|
1197
|
+
* @param opts - Options (method filter, timeoutMs, maxChars for response body)
|
|
1198
|
+
* @returns Request method, postData, response status, and response body
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* ```ts
|
|
1202
|
+
* const reqPromise = page.waitForRequest('/api/submit', { method: 'POST' });
|
|
1203
|
+
* await page.click('e5'); // submit a form
|
|
1204
|
+
* const req = await reqPromise;
|
|
1205
|
+
* console.log(req.postData); // form body
|
|
1206
|
+
* console.log(req.status, req.responseBody); // response
|
|
1207
|
+
* ```
|
|
1208
|
+
*/
|
|
1209
|
+
waitForRequest(url: string, opts?: {
|
|
1210
|
+
method?: string;
|
|
1211
|
+
timeoutMs?: number;
|
|
1212
|
+
maxChars?: number;
|
|
1213
|
+
}): Promise<RequestResult>;
|
|
1139
1214
|
/**
|
|
1140
1215
|
* Get console messages captured from the page.
|
|
1141
1216
|
*
|
|
@@ -1425,8 +1500,8 @@ declare class CrawlPage {
|
|
|
1425
1500
|
* ```ts
|
|
1426
1501
|
* import { BrowserClaw } from 'browserclaw';
|
|
1427
1502
|
*
|
|
1428
|
-
* const browser = await BrowserClaw.launch({
|
|
1429
|
-
* const page = await browser.
|
|
1503
|
+
* const browser = await BrowserClaw.launch({ url: 'https://example.com' });
|
|
1504
|
+
* const page = await browser.currentPage();
|
|
1430
1505
|
*
|
|
1431
1506
|
* const { snapshot, refs } = await page.snapshot();
|
|
1432
1507
|
* console.log(snapshot); // AI-readable page tree
|
|
@@ -1453,14 +1528,15 @@ declare class BrowserClaw {
|
|
|
1453
1528
|
*
|
|
1454
1529
|
* @example
|
|
1455
1530
|
* ```ts
|
|
1456
|
-
* //
|
|
1457
|
-
* const browser = await BrowserClaw.launch();
|
|
1531
|
+
* // Launch and navigate to a URL
|
|
1532
|
+
* const browser = await BrowserClaw.launch({ url: 'https://example.com' });
|
|
1458
1533
|
*
|
|
1459
1534
|
* // Headless mode
|
|
1460
|
-
* const browser = await BrowserClaw.launch({ headless: true });
|
|
1535
|
+
* const browser = await BrowserClaw.launch({ url: 'https://example.com', headless: true });
|
|
1461
1536
|
*
|
|
1462
1537
|
* // Specific browser
|
|
1463
1538
|
* const browser = await BrowserClaw.launch({
|
|
1539
|
+
* url: 'https://example.com',
|
|
1464
1540
|
* executablePath: '/usr/bin/google-chrome',
|
|
1465
1541
|
* });
|
|
1466
1542
|
* ```
|
|
@@ -1506,6 +1582,26 @@ declare class BrowserClaw {
|
|
|
1506
1582
|
* @returns Array of tab information objects
|
|
1507
1583
|
*/
|
|
1508
1584
|
tabs(): Promise<BrowserTab[]>;
|
|
1585
|
+
/**
|
|
1586
|
+
* Wait for a tab matching the given criteria and return a page handle.
|
|
1587
|
+
*
|
|
1588
|
+
* Polls open tabs until one matches, then focuses it and returns a CrawlPage.
|
|
1589
|
+
*
|
|
1590
|
+
* @param opts - Match criteria (urlContains, titleContains) and timeout
|
|
1591
|
+
* @returns A CrawlPage for the matched tab
|
|
1592
|
+
*
|
|
1593
|
+
* @example
|
|
1594
|
+
* ```ts
|
|
1595
|
+
* await page.click('e5'); // opens a new tab
|
|
1596
|
+
* const appPage = await browser.waitForTab({ urlContains: 'app-web' });
|
|
1597
|
+
* const { snapshot } = await appPage.snapshot();
|
|
1598
|
+
* ```
|
|
1599
|
+
*/
|
|
1600
|
+
waitForTab(opts: {
|
|
1601
|
+
urlContains?: string;
|
|
1602
|
+
titleContains?: string;
|
|
1603
|
+
timeoutMs?: number;
|
|
1604
|
+
}): Promise<CrawlPage>;
|
|
1509
1605
|
/**
|
|
1510
1606
|
* Bring a tab to the foreground.
|
|
1511
1607
|
*
|
|
@@ -1717,6 +1813,15 @@ declare function getRestoredPageForTarget(opts: {
|
|
|
1717
1813
|
targetId?: string;
|
|
1718
1814
|
}): Promise<Page>;
|
|
1719
1815
|
|
|
1816
|
+
declare function pressAndHoldViaCdp(opts: {
|
|
1817
|
+
cdpUrl: string;
|
|
1818
|
+
targetId?: string;
|
|
1819
|
+
x: number;
|
|
1820
|
+
y: number;
|
|
1821
|
+
delay?: number;
|
|
1822
|
+
holdMs?: number;
|
|
1823
|
+
}): Promise<void>;
|
|
1824
|
+
|
|
1720
1825
|
/**
|
|
1721
1826
|
* Comprehensive browser stealth evasions.
|
|
1722
1827
|
*
|
|
@@ -1755,4 +1860,4 @@ declare function waitForChallengeViaPlaywright(opts: {
|
|
|
1755
1860
|
pollMs?: number;
|
|
1756
1861
|
}): Promise<ChallengeWaitResult>;
|
|
1757
1862
|
|
|
1758
|
-
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChallengeInfo, type ChallengeKind, type ChallengeWaitResult, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogEvent, type DialogHandler, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, STEALTH_SCRIPT, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
|
1863
|
+
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChallengeInfo, type ChallengeKind, type ChallengeWaitResult, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogEvent, type DialogHandler, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type RequestResult, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, STEALTH_SCRIPT, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, pressAndHoldViaCdp, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ type BatchAction = {
|
|
|
77
77
|
url?: string;
|
|
78
78
|
loadState?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
79
79
|
fn?: string;
|
|
80
|
+
arg?: unknown;
|
|
80
81
|
targetId?: string;
|
|
81
82
|
timeoutMs?: number;
|
|
82
83
|
} | {
|
|
@@ -168,6 +169,8 @@ interface ChromeExecutable {
|
|
|
168
169
|
}
|
|
169
170
|
/** Options for launching a new browser instance. */
|
|
170
171
|
interface LaunchOptions {
|
|
172
|
+
/** URL to navigate to after launch. If omitted, the initial tab stays on `about:blank`. */
|
|
173
|
+
url?: string;
|
|
171
174
|
/** Run in headless mode (no visible window). Default: `false` */
|
|
172
175
|
headless?: boolean;
|
|
173
176
|
/** Path to a specific browser executable. Auto-detected if omitted. */
|
|
@@ -184,6 +187,8 @@ interface LaunchOptions {
|
|
|
184
187
|
profileColor?: string;
|
|
185
188
|
/** Additional Chrome command-line arguments (e.g. `['--start-maximized']`). */
|
|
186
189
|
chromeArgs?: string[];
|
|
190
|
+
/** Ignore HTTPS certificate errors (e.g. expired local dev certs). Default: `false` */
|
|
191
|
+
ignoreHTTPSErrors?: boolean;
|
|
187
192
|
/**
|
|
188
193
|
* SSRF policy controlling which URLs navigation is allowed to reach.
|
|
189
194
|
* Defaults to trusted-network mode (private/internal addresses allowed).
|
|
@@ -249,6 +254,10 @@ interface RoleRefInfo {
|
|
|
249
254
|
name?: string;
|
|
250
255
|
/** Disambiguation index when multiple elements share the same role + name */
|
|
251
256
|
nth?: number;
|
|
257
|
+
/** Whether the element is disabled (from `[disabled]` or `aria-disabled`) */
|
|
258
|
+
disabled?: boolean;
|
|
259
|
+
/** Whether a checkbox/radio/switch is checked */
|
|
260
|
+
checked?: boolean | 'mixed';
|
|
252
261
|
}
|
|
253
262
|
/** Map of ref IDs (e.g. `'e1'`, `'e2'`) to their element information. */
|
|
254
263
|
type RoleRefs = Record<string, RoleRefInfo>;
|
|
@@ -375,6 +384,8 @@ interface ClickOptions {
|
|
|
375
384
|
delayMs?: number;
|
|
376
385
|
/** Timeout in milliseconds. Default: `8000` */
|
|
377
386
|
timeoutMs?: number;
|
|
387
|
+
/** Force click even if element is hidden or covered. Dispatches the event regardless of visibility. */
|
|
388
|
+
force?: boolean;
|
|
378
389
|
}
|
|
379
390
|
/** Options for type actions. */
|
|
380
391
|
interface TypeOptions {
|
|
@@ -402,8 +413,10 @@ interface WaitOptions {
|
|
|
402
413
|
url?: string;
|
|
403
414
|
/** Wait for a specific page load state */
|
|
404
415
|
loadState?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
405
|
-
/** Wait until a JavaScript function returns truthy (evaluated in browser context) */
|
|
406
|
-
fn?: string;
|
|
416
|
+
/** Wait until a JavaScript function returns truthy (evaluated in browser context). Accepts a string or a serializable function. */
|
|
417
|
+
fn?: string | ((arg?: unknown) => unknown);
|
|
418
|
+
/** Serializable argument passed to `fn` in the browser context. Use an array or object to pass multiple values. */
|
|
419
|
+
arg?: unknown;
|
|
407
420
|
/** Timeout for each condition in milliseconds. Default: `20000` */
|
|
408
421
|
timeoutMs?: number;
|
|
409
422
|
}
|
|
@@ -532,6 +545,23 @@ interface DialogEvent {
|
|
|
532
545
|
}
|
|
533
546
|
/** Callback for persistent dialog handling. */
|
|
534
547
|
type DialogHandler = (event: DialogEvent) => void | Promise<void>;
|
|
548
|
+
/** Result of waiting for a network request to complete. */
|
|
549
|
+
interface RequestResult {
|
|
550
|
+
/** The final request URL */
|
|
551
|
+
url: string;
|
|
552
|
+
/** HTTP method (e.g. `'GET'`, `'POST'`) */
|
|
553
|
+
method: string;
|
|
554
|
+
/** Request body (for POST/PUT/PATCH requests) */
|
|
555
|
+
postData?: string;
|
|
556
|
+
/** HTTP response status code */
|
|
557
|
+
status: number;
|
|
558
|
+
/** Whether the response status was 2xx */
|
|
559
|
+
ok: boolean;
|
|
560
|
+
/** Response body text */
|
|
561
|
+
responseBody?: string;
|
|
562
|
+
/** Whether the response body was truncated due to maxChars */
|
|
563
|
+
truncated?: boolean;
|
|
564
|
+
}
|
|
535
565
|
/** Result of intercepting a response body. */
|
|
536
566
|
interface ResponseBodyResult {
|
|
537
567
|
/** The response URL */
|
|
@@ -717,6 +747,26 @@ declare class CrawlPage {
|
|
|
717
747
|
clickCount?: number;
|
|
718
748
|
delayMs?: number;
|
|
719
749
|
}): Promise<void>;
|
|
750
|
+
/**
|
|
751
|
+
* Press and hold at page coordinates using raw CDP events.
|
|
752
|
+
*
|
|
753
|
+
* Bypasses Playwright's automation layer by dispatching CDP
|
|
754
|
+
* `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
|
|
755
|
+
* that detect automated clicks.
|
|
756
|
+
*
|
|
757
|
+
* @param x - X coordinate in CSS pixels
|
|
758
|
+
* @param y - Y coordinate in CSS pixels
|
|
759
|
+
* @param opts - Options (delay: ms before press, holdMs: hold duration)
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* ```ts
|
|
763
|
+
* await page.pressAndHold(400, 300, { delay: 150, holdMs: 5000 });
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
pressAndHold(x: number, y: number, opts?: {
|
|
767
|
+
delay?: number;
|
|
768
|
+
holdMs?: number;
|
|
769
|
+
}): Promise<void>;
|
|
720
770
|
/**
|
|
721
771
|
* Click an element by its visible text content (no snapshot/ref needed).
|
|
722
772
|
*
|
|
@@ -754,6 +804,7 @@ declare class CrawlPage {
|
|
|
754
804
|
* ```
|
|
755
805
|
*/
|
|
756
806
|
clickByRole(role: string, name?: string, opts?: {
|
|
807
|
+
index?: number;
|
|
757
808
|
button?: 'left' | 'right' | 'middle';
|
|
758
809
|
modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[];
|
|
759
810
|
timeoutMs?: number;
|
|
@@ -1136,6 +1187,30 @@ declare class CrawlPage {
|
|
|
1136
1187
|
timeoutMs?: number;
|
|
1137
1188
|
maxChars?: number;
|
|
1138
1189
|
}): Promise<ResponseBodyResult>;
|
|
1190
|
+
/**
|
|
1191
|
+
* Wait for a network request matching a URL pattern and return request + response details.
|
|
1192
|
+
*
|
|
1193
|
+
* Unlike `networkRequests()` which only captures metadata, this method captures
|
|
1194
|
+
* the full request body (POST data) and response body.
|
|
1195
|
+
*
|
|
1196
|
+
* @param url - URL string or pattern to match (supports `*` wildcards and substring matching)
|
|
1197
|
+
* @param opts - Options (method filter, timeoutMs, maxChars for response body)
|
|
1198
|
+
* @returns Request method, postData, response status, and response body
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* ```ts
|
|
1202
|
+
* const reqPromise = page.waitForRequest('/api/submit', { method: 'POST' });
|
|
1203
|
+
* await page.click('e5'); // submit a form
|
|
1204
|
+
* const req = await reqPromise;
|
|
1205
|
+
* console.log(req.postData); // form body
|
|
1206
|
+
* console.log(req.status, req.responseBody); // response
|
|
1207
|
+
* ```
|
|
1208
|
+
*/
|
|
1209
|
+
waitForRequest(url: string, opts?: {
|
|
1210
|
+
method?: string;
|
|
1211
|
+
timeoutMs?: number;
|
|
1212
|
+
maxChars?: number;
|
|
1213
|
+
}): Promise<RequestResult>;
|
|
1139
1214
|
/**
|
|
1140
1215
|
* Get console messages captured from the page.
|
|
1141
1216
|
*
|
|
@@ -1425,8 +1500,8 @@ declare class CrawlPage {
|
|
|
1425
1500
|
* ```ts
|
|
1426
1501
|
* import { BrowserClaw } from 'browserclaw';
|
|
1427
1502
|
*
|
|
1428
|
-
* const browser = await BrowserClaw.launch({
|
|
1429
|
-
* const page = await browser.
|
|
1503
|
+
* const browser = await BrowserClaw.launch({ url: 'https://example.com' });
|
|
1504
|
+
* const page = await browser.currentPage();
|
|
1430
1505
|
*
|
|
1431
1506
|
* const { snapshot, refs } = await page.snapshot();
|
|
1432
1507
|
* console.log(snapshot); // AI-readable page tree
|
|
@@ -1453,14 +1528,15 @@ declare class BrowserClaw {
|
|
|
1453
1528
|
*
|
|
1454
1529
|
* @example
|
|
1455
1530
|
* ```ts
|
|
1456
|
-
* //
|
|
1457
|
-
* const browser = await BrowserClaw.launch();
|
|
1531
|
+
* // Launch and navigate to a URL
|
|
1532
|
+
* const browser = await BrowserClaw.launch({ url: 'https://example.com' });
|
|
1458
1533
|
*
|
|
1459
1534
|
* // Headless mode
|
|
1460
|
-
* const browser = await BrowserClaw.launch({ headless: true });
|
|
1535
|
+
* const browser = await BrowserClaw.launch({ url: 'https://example.com', headless: true });
|
|
1461
1536
|
*
|
|
1462
1537
|
* // Specific browser
|
|
1463
1538
|
* const browser = await BrowserClaw.launch({
|
|
1539
|
+
* url: 'https://example.com',
|
|
1464
1540
|
* executablePath: '/usr/bin/google-chrome',
|
|
1465
1541
|
* });
|
|
1466
1542
|
* ```
|
|
@@ -1506,6 +1582,26 @@ declare class BrowserClaw {
|
|
|
1506
1582
|
* @returns Array of tab information objects
|
|
1507
1583
|
*/
|
|
1508
1584
|
tabs(): Promise<BrowserTab[]>;
|
|
1585
|
+
/**
|
|
1586
|
+
* Wait for a tab matching the given criteria and return a page handle.
|
|
1587
|
+
*
|
|
1588
|
+
* Polls open tabs until one matches, then focuses it and returns a CrawlPage.
|
|
1589
|
+
*
|
|
1590
|
+
* @param opts - Match criteria (urlContains, titleContains) and timeout
|
|
1591
|
+
* @returns A CrawlPage for the matched tab
|
|
1592
|
+
*
|
|
1593
|
+
* @example
|
|
1594
|
+
* ```ts
|
|
1595
|
+
* await page.click('e5'); // opens a new tab
|
|
1596
|
+
* const appPage = await browser.waitForTab({ urlContains: 'app-web' });
|
|
1597
|
+
* const { snapshot } = await appPage.snapshot();
|
|
1598
|
+
* ```
|
|
1599
|
+
*/
|
|
1600
|
+
waitForTab(opts: {
|
|
1601
|
+
urlContains?: string;
|
|
1602
|
+
titleContains?: string;
|
|
1603
|
+
timeoutMs?: number;
|
|
1604
|
+
}): Promise<CrawlPage>;
|
|
1509
1605
|
/**
|
|
1510
1606
|
* Bring a tab to the foreground.
|
|
1511
1607
|
*
|
|
@@ -1717,6 +1813,15 @@ declare function getRestoredPageForTarget(opts: {
|
|
|
1717
1813
|
targetId?: string;
|
|
1718
1814
|
}): Promise<Page>;
|
|
1719
1815
|
|
|
1816
|
+
declare function pressAndHoldViaCdp(opts: {
|
|
1817
|
+
cdpUrl: string;
|
|
1818
|
+
targetId?: string;
|
|
1819
|
+
x: number;
|
|
1820
|
+
y: number;
|
|
1821
|
+
delay?: number;
|
|
1822
|
+
holdMs?: number;
|
|
1823
|
+
}): Promise<void>;
|
|
1824
|
+
|
|
1720
1825
|
/**
|
|
1721
1826
|
* Comprehensive browser stealth evasions.
|
|
1722
1827
|
*
|
|
@@ -1755,4 +1860,4 @@ declare function waitForChallengeViaPlaywright(opts: {
|
|
|
1755
1860
|
pollMs?: number;
|
|
1756
1861
|
}): Promise<ChallengeWaitResult>;
|
|
1757
1862
|
|
|
1758
|
-
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChallengeInfo, type ChallengeKind, type ChallengeWaitResult, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogEvent, type DialogHandler, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, STEALTH_SCRIPT, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
|
1863
|
+
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChallengeInfo, type ChallengeKind, type ChallengeWaitResult, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogEvent, type DialogHandler, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type RequestResult, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, STEALTH_SCRIPT, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, pressAndHoldViaCdp, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|