playwright_iframe_click
Click elements within iframes during browser automation by specifying both iframe and element selectors to interact with nested page 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:56-70 (handler)The core handler implementation for 'playwright_iframe_click' in the IframeClickTool class. It locates the iframe using frameLocator, checks if it exists, clicks the specified element inside it, and returns a success message.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:131-145 (schema)The tool definition including name, description, and input schema (iframeSelector and selector required) for 'playwright_iframe_click'.{ 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:393-393 (registration)Instantiation of the IframeClickTool instance in the initializeTools function.if (!iframeClickTool) iframeClickTool = new IframeClickTool(server);
- src/toolHandler.ts:589-590 (registration)The switch case in handleToolCall function that dispatches 'playwright_iframe_click' calls to the iframeClickTool's execute method.return await iframeClickTool.execute(args, context);
- src/toolHandler.ts:76-76 (registration)Type declaration for the iframeClickTool instance variable.let iframeClickTool: IframeClickTool;