playwright_iframe_click
Click an element within an iframe on a webpage using CSS selectors for the iframe and target element, enabling precise interactions in browser automation scenarios.
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)IframeClickTool class implementation. Uses page.frameLocator to find iframe and clicks the specified selector within it using Playwright.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:125-135 (schema)JSON schema definition for the playwright_iframe_click tool inputs.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:487-488 (registration)Switch case in handleToolCall that registers and dispatches to the IframeClickTool handler.case "playwright_iframe_click": return await iframeClickTool.execute(args, context);
- src/toolHandler.ts:322-322 (registration)Instantiation of IframeClickTool instance in initializeTools function.if (!iframeClickTool) iframeClickTool = new IframeClickTool(server);
- src/tools.ts:454-454 (registration)Inclusion in BROWSER_TOOLS array for conditional browser setup."playwright_iframe_click",