playwright_iframe_click
Click elements within iframes on web pages using CSS selectors for both the iframe and the target element. Enables precise browser automation for interacting with embedded content.
Instructions
Click an element in an iframe on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| iframeSelector | Yes | CSS selector for the iframe containing the element to click | |
| selector | Yes | CSS selector for the element to click |
Implementation Reference
- src/tools/browser/interaction.ts:51-66 (handler)The core handler implementation for the 'playwright_iframe_click' tool. Uses Playwright's frameLocator to locate the iframe and click the specified element inside it.export class IframeClickTool extends BrowserToolBase { /** * Execute the iframe click tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { return this.safeExecute(context, async (page) => { const frame = page.frameLocator(args.iframeSelector); if (!frame) { return createErrorResponse(`Iframe not found: ${args.iframeSelector}`); } await frame.locator(args.selector).click(); return createSuccessResponse(`Clicked element ${args.selector} inside iframe ${args.iframeSelector}`); }); } }
- src/tools.ts:124-135 (schema)The input/output schema definition for the tool, specifying parameters iframeSelector and selector.{ name: "playwright_iframe_click", description: "Click an element in an iframe on the page", inputSchema: { type: "object", properties: { iframeSelector: { type: "string", description: "CSS selector for the iframe containing the element to click" }, selector: { type: "string", description: "CSS selector for the element to click" }, }, required: ["iframeSelector", "selector"], }, },
- src/toolHandler.ts:484-488 (registration)Dispatch registration in the main tool handler switch statement, routing calls to the IframeClickTool instance.case "playwright_click": return await clickTool.execute(args, context); case "playwright_iframe_click": return await iframeClickTool.execute(args, context);
- src/index.ts:22-27 (registration)Registers all tools (including schema for playwright_iframe_click) with the MCP server via createToolDefinitions() and setupRequestHandlers.// Create tool definitions const TOOLS = createToolDefinitions(); // Setup request handlers setupRequestHandlers(server, TOOLS);
- src/tools.ts:453-454 (registration)Includes 'playwright_iframe_click' in the BROWSER_TOOLS array used for conditional browser launching."playwright_click", "playwright_iframe_click",