browser_console_messages
Capture and retrieve console messages for automated browser testing using Playwright. Integrates with Cloudflare Workers for streamlined web navigation and interaction.
Instructions
Returns all console messages
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/console.ts:29-42 (handler)The handler function that executes the tool logic: retrieves console messages from the current browser tab using context.currentTabOrDie().consoleMessages(), formats them into a newline-separated log string with type prefixes, and returns an action object to display the log as text content.handle: async context => { const messages = context.currentTabOrDie().consoleMessages(); const log = messages.map(message => `[${message.type().toUpperCase()}] ${message.text()}`).join('\n'); return { code: [`// <internal code to get console messages>`], action: async () => { return { content: [{ type: 'text', text: log }] }; }, captureSnapshot: false, waitForNetwork: false, }; },
- src/tools/console.ts:22-28 (schema)Input/output schema definition for the tool, specifying name, title, description, empty input schema (no parameters), and readOnly type.schema: { name: 'browser_console_messages', title: 'Get console messages', description: 'Returns all console messages', inputSchema: z.object({}), type: 'readOnly', },
- src/tools.ts:18-37 (registration)Imports the console tool module (which exports the browser_console_messages tool) and spreads it into the snapshotTools array for registration.import console from './tools/console.js'; import dialogs from './tools/dialogs.js'; import files from './tools/files.js'; import install from './tools/install.js'; import keyboard from './tools/keyboard.js'; import navigate from './tools/navigate.js'; import network from './tools/network.js'; import pdf from './tools/pdf.js'; import snapshot from './tools/snapshot.js'; import tabs from './tools/tabs.js'; import screenshot from './tools/screenshot.js'; import testing from './tools/testing.js'; import vision from './tools/vision.js'; import wait from './tools/wait.js'; import type { Tool } from './tools/tool.js'; export const snapshotTools: Tool<any>[] = [ ...common(true), ...console,
- src/tools.ts:54-54 (registration)Spreads the console tool (containing browser_console_messages) into the visionTools array for registration....console,