diff --git a/src/actions.ts b/src/actions.ts index a8402f3..a4a0580 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -177,6 +177,14 @@ export function toAIFriendlyError(error: unknown, selector: string): Error { ); } + // Handle general timeout (element exists but action couldn't complete) + if (message.includes('Timeout') && message.includes('exceeded')) { + return new Error( + `Action on "${selector}" timed out. The element may be blocked, still loading, or not interactable. ` + + `Run 'snapshot' to check the current page state.` + ); + } + // Handle element not found (timeout waiting for element) if ( message.includes('waiting for') && diff --git a/src/browser.test.ts b/src/browser.test.ts index 55e483d..a145d28 100644 --- a/src/browser.test.ts +++ b/src/browser.test.ts @@ -402,6 +402,7 @@ describe('BrowserManager', () => { { url: () => 'http://anothersite.com', on: vi.fn() }, ], on: vi.fn(), + setDefaultTimeout: vi.fn(), }, ], close: vi.fn(), diff --git a/src/browser.ts b/src/browser.ts index 00b3bd2..19a6180 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1029,6 +1029,7 @@ export class BrowserManager { this.cdpEndpoint = cdpEndpoint; for (const context of contexts) { + context.setDefaultTimeout(10000); this.contexts.push(context); this.setupContextTracking(context); }