browser-pilot 0.0.7 → 0.0.8

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.
@@ -189,9 +189,25 @@ interface InteractiveElement {
189
189
  /** Whether the element is disabled */
190
190
  disabled?: boolean;
191
191
  }
192
+ interface FailureHint {
193
+ /** Suggested selector */
194
+ selector: string;
195
+ /** Why this might work */
196
+ reason: string;
197
+ /** Confidence level */
198
+ confidence: 'high' | 'medium' | 'low';
199
+ /** Element info */
200
+ element: {
201
+ ref: string;
202
+ role: string;
203
+ name: string;
204
+ disabled?: boolean;
205
+ };
206
+ }
192
207
  declare class ElementNotFoundError extends Error {
193
208
  selectors: string[];
194
- constructor(selectors: string | string[]);
209
+ hints?: FailureHint[];
210
+ constructor(selectors: string | string[], hints?: FailureHint[]);
195
211
  }
196
212
  declare class TimeoutError extends Error {
197
213
  constructor(message?: string);
@@ -466,6 +482,7 @@ interface ClearCookiesOptions {
466
482
 
467
483
  declare class Page {
468
484
  private cdp;
485
+ private _targetId;
469
486
  private rootNodeId;
470
487
  private batchExecutor;
471
488
  private emulationState;
@@ -484,12 +501,23 @@ declare class Page {
484
501
  private frameExecutionContexts;
485
502
  /** Current frame's execution context ID (null = main frame default) */
486
503
  private currentFrameContextId;
487
- constructor(cdp: CDPClient);
504
+ /** Last matched selector from findElement (for selectorUsed tracking) */
505
+ private _lastMatchedSelector;
506
+ constructor(cdp: CDPClient, targetId: string);
507
+ /**
508
+ * Get the CDP target ID for this page
509
+ */
510
+ get targetId(): string;
488
511
  /**
489
512
  * Get the underlying CDP client for advanced operations.
490
513
  * Use with caution - prefer high-level Page methods when possible.
491
514
  */
492
515
  get cdpClient(): CDPClient;
516
+ /**
517
+ * Get the last matched selector from findElement (for selectorUsed tracking).
518
+ * Returns undefined if no selector has been matched yet.
519
+ */
520
+ getLastMatchedSelector(): string | undefined;
493
521
  /**
494
522
  * Initialize the page (enable required CDP domains)
495
523
  */
@@ -557,6 +585,9 @@ declare class Page {
557
585
  * - 'auto' (default): Attempt to detect navigation for 1 second, then assume client-side handling
558
586
  * - true: Wait for full navigation (traditional forms)
559
587
  * - false: Return immediately (AJAX forms where you'll wait for something else)
588
+ *
589
+ * When targeting a <form> element directly, uses form.requestSubmit() which fires
590
+ * the submit event and triggers HTML5 validation.
560
591
  */
561
592
  submit(selector: string | string[], options?: SubmitOptions): Promise<boolean>;
562
593
  /**
@@ -851,6 +882,7 @@ declare class Page {
851
882
  /**
852
883
  * Action/Step types for batch execution
853
884
  */
885
+
854
886
  type ActionType = 'goto' | 'click' | 'fill' | 'type' | 'select' | 'check' | 'uncheck' | 'submit' | 'press' | 'focus' | 'hover' | 'scroll' | 'wait' | 'snapshot' | 'screenshot' | 'evaluate' | 'text' | 'switchFrame' | 'switchToMain';
855
887
  interface Step {
856
888
  /** Action type */
@@ -927,6 +959,8 @@ interface StepResult {
927
959
  result?: unknown;
928
960
  /** Text content (for text action) */
929
961
  text?: string;
962
+ /** Failure hints when element not found */
963
+ hints?: FailureHint[];
930
964
  }
931
965
  interface BatchResult {
932
966
  /** Whether all steps succeeded */
@@ -939,4 +973,4 @@ interface BatchResult {
939
973
  totalDurationMs: number;
940
974
  }
941
975
 
942
- export { type WaitResult as $, type ActionType as A, type BatchOptions as B, type ConsoleHandler as C, type Dialog as D, type ElementInfo as E, type FileInput as F, type GeolocationOptions as G, type FailRequestOptions as H, type InteractiveElement as I, type FulfillRequestOptions as J, type InterceptedRequest as K, type RequestActions as L, type ResourceType as M, NavigationError as N, type RouteOptions as O, Page as P, type ClearCookiesOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type UserAgentMetadata as U, type ViewportOptions as V, type WaitForOptions as W, type Cookie as X, type DeleteCookieOptions as Y, type SetCookieOptions as Z, type WaitOptions as _, type RequestHandler as a, type WaitState as a0, waitForAnyElement as a1, waitForElement as a2, waitForNavigation as a3, waitForNetworkIdle as a4, type BatchResult as b, type StepResult as c, type ActionOptions as d, type ActionResult as e, type ConsoleMessage as f, type ConsoleMessageType as g, type CustomSelectConfig as h, type DialogHandler as i, type DialogType as j, type Download as k, ElementNotFoundError as l, type EmulationState as m, type ErrorHandler as n, type FillOptions as o, type NetworkIdleOptions as p, type PageError as q, type PageSnapshot as r, type SnapshotNode as s, type SubmitOptions as t, type TypeOptions as u, type UserAgentOptions as v, type DeviceDescriptor as w, type DeviceName as x, devices as y, type ContinueRequestOptions as z };
976
+ export { type WaitResult as $, type ActionType as A, type BatchOptions as B, type ConsoleHandler as C, type Dialog as D, type ElementInfo as E, type FileInput as F, type GeolocationOptions as G, type FailRequestOptions as H, type InteractiveElement as I, type FulfillRequestOptions as J, type InterceptedRequest as K, type RequestActions as L, type ResourceType as M, NavigationError as N, type RouteOptions as O, Page as P, type ClearCookiesOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type UserAgentMetadata as U, type ViewportOptions as V, type WaitForOptions as W, type Cookie as X, type DeleteCookieOptions as Y, type SetCookieOptions as Z, type WaitOptions as _, type RequestHandler as a, type WaitState as a0, waitForAnyElement as a1, waitForElement as a2, waitForNavigation as a3, waitForNetworkIdle as a4, type FailureHint as a5, type BatchResult as b, type StepResult as c, type ActionOptions as d, type ActionResult as e, type ConsoleMessage as f, type ConsoleMessageType as g, type CustomSelectConfig as h, type DialogHandler as i, type DialogType as j, type Download as k, ElementNotFoundError as l, type EmulationState as m, type ErrorHandler as n, type FillOptions as o, type NetworkIdleOptions as p, type PageError as q, type PageSnapshot as r, type SnapshotNode as s, type SubmitOptions as t, type TypeOptions as u, type UserAgentOptions as v, type DeviceDescriptor as w, type DeviceName as x, devices as y, type ContinueRequestOptions as z };
@@ -189,9 +189,25 @@ interface InteractiveElement {
189
189
  /** Whether the element is disabled */
190
190
  disabled?: boolean;
191
191
  }
192
+ interface FailureHint {
193
+ /** Suggested selector */
194
+ selector: string;
195
+ /** Why this might work */
196
+ reason: string;
197
+ /** Confidence level */
198
+ confidence: 'high' | 'medium' | 'low';
199
+ /** Element info */
200
+ element: {
201
+ ref: string;
202
+ role: string;
203
+ name: string;
204
+ disabled?: boolean;
205
+ };
206
+ }
192
207
  declare class ElementNotFoundError extends Error {
193
208
  selectors: string[];
194
- constructor(selectors: string | string[]);
209
+ hints?: FailureHint[];
210
+ constructor(selectors: string | string[], hints?: FailureHint[]);
195
211
  }
196
212
  declare class TimeoutError extends Error {
197
213
  constructor(message?: string);
@@ -466,6 +482,7 @@ interface ClearCookiesOptions {
466
482
 
467
483
  declare class Page {
468
484
  private cdp;
485
+ private _targetId;
469
486
  private rootNodeId;
470
487
  private batchExecutor;
471
488
  private emulationState;
@@ -484,12 +501,23 @@ declare class Page {
484
501
  private frameExecutionContexts;
485
502
  /** Current frame's execution context ID (null = main frame default) */
486
503
  private currentFrameContextId;
487
- constructor(cdp: CDPClient);
504
+ /** Last matched selector from findElement (for selectorUsed tracking) */
505
+ private _lastMatchedSelector;
506
+ constructor(cdp: CDPClient, targetId: string);
507
+ /**
508
+ * Get the CDP target ID for this page
509
+ */
510
+ get targetId(): string;
488
511
  /**
489
512
  * Get the underlying CDP client for advanced operations.
490
513
  * Use with caution - prefer high-level Page methods when possible.
491
514
  */
492
515
  get cdpClient(): CDPClient;
516
+ /**
517
+ * Get the last matched selector from findElement (for selectorUsed tracking).
518
+ * Returns undefined if no selector has been matched yet.
519
+ */
520
+ getLastMatchedSelector(): string | undefined;
493
521
  /**
494
522
  * Initialize the page (enable required CDP domains)
495
523
  */
@@ -557,6 +585,9 @@ declare class Page {
557
585
  * - 'auto' (default): Attempt to detect navigation for 1 second, then assume client-side handling
558
586
  * - true: Wait for full navigation (traditional forms)
559
587
  * - false: Return immediately (AJAX forms where you'll wait for something else)
588
+ *
589
+ * When targeting a <form> element directly, uses form.requestSubmit() which fires
590
+ * the submit event and triggers HTML5 validation.
560
591
  */
561
592
  submit(selector: string | string[], options?: SubmitOptions): Promise<boolean>;
562
593
  /**
@@ -851,6 +882,7 @@ declare class Page {
851
882
  /**
852
883
  * Action/Step types for batch execution
853
884
  */
885
+
854
886
  type ActionType = 'goto' | 'click' | 'fill' | 'type' | 'select' | 'check' | 'uncheck' | 'submit' | 'press' | 'focus' | 'hover' | 'scroll' | 'wait' | 'snapshot' | 'screenshot' | 'evaluate' | 'text' | 'switchFrame' | 'switchToMain';
855
887
  interface Step {
856
888
  /** Action type */
@@ -927,6 +959,8 @@ interface StepResult {
927
959
  result?: unknown;
928
960
  /** Text content (for text action) */
929
961
  text?: string;
962
+ /** Failure hints when element not found */
963
+ hints?: FailureHint[];
930
964
  }
931
965
  interface BatchResult {
932
966
  /** Whether all steps succeeded */
@@ -939,4 +973,4 @@ interface BatchResult {
939
973
  totalDurationMs: number;
940
974
  }
941
975
 
942
- export { type WaitResult as $, type ActionType as A, type BatchOptions as B, type ConsoleHandler as C, type Dialog as D, type ElementInfo as E, type FileInput as F, type GeolocationOptions as G, type FailRequestOptions as H, type InteractiveElement as I, type FulfillRequestOptions as J, type InterceptedRequest as K, type RequestActions as L, type ResourceType as M, NavigationError as N, type RouteOptions as O, Page as P, type ClearCookiesOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type UserAgentMetadata as U, type ViewportOptions as V, type WaitForOptions as W, type Cookie as X, type DeleteCookieOptions as Y, type SetCookieOptions as Z, type WaitOptions as _, type RequestHandler as a, type WaitState as a0, waitForAnyElement as a1, waitForElement as a2, waitForNavigation as a3, waitForNetworkIdle as a4, type BatchResult as b, type StepResult as c, type ActionOptions as d, type ActionResult as e, type ConsoleMessage as f, type ConsoleMessageType as g, type CustomSelectConfig as h, type DialogHandler as i, type DialogType as j, type Download as k, ElementNotFoundError as l, type EmulationState as m, type ErrorHandler as n, type FillOptions as o, type NetworkIdleOptions as p, type PageError as q, type PageSnapshot as r, type SnapshotNode as s, type SubmitOptions as t, type TypeOptions as u, type UserAgentOptions as v, type DeviceDescriptor as w, type DeviceName as x, devices as y, type ContinueRequestOptions as z };
976
+ export { type WaitResult as $, type ActionType as A, type BatchOptions as B, type ConsoleHandler as C, type Dialog as D, type ElementInfo as E, type FileInput as F, type GeolocationOptions as G, type FailRequestOptions as H, type InteractiveElement as I, type FulfillRequestOptions as J, type InterceptedRequest as K, type RequestActions as L, type ResourceType as M, NavigationError as N, type RouteOptions as O, Page as P, type ClearCookiesOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type UserAgentMetadata as U, type ViewportOptions as V, type WaitForOptions as W, type Cookie as X, type DeleteCookieOptions as Y, type SetCookieOptions as Z, type WaitOptions as _, type RequestHandler as a, type WaitState as a0, waitForAnyElement as a1, waitForElement as a2, waitForNavigation as a3, waitForNetworkIdle as a4, type FailureHint as a5, type BatchResult as b, type StepResult as c, type ActionOptions as d, type ActionResult as e, type ConsoleMessage as f, type ConsoleMessageType as g, type CustomSelectConfig as h, type DialogHandler as i, type DialogType as j, type Download as k, ElementNotFoundError as l, type EmulationState as m, type ErrorHandler as n, type FillOptions as o, type NetworkIdleOptions as p, type PageError as q, type PageSnapshot as r, type SnapshotNode as s, type SubmitOptions as t, type TypeOptions as u, type UserAgentOptions as v, type DeviceDescriptor as w, type DeviceName as x, devices as y, type ContinueRequestOptions as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-pilot",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Lightweight CDP-based browser automation for Node.js, Bun, and Cloudflare Workers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",