playwright_iframe_click
Click elements within iframes using CSS selectors to interact with embedded content in web pages.
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 execute method of IframeClickTool performs the iframe click using Playwright's frameLocator to select the iframe and locator.click() on the target element within it. It handles the case where the iframe is not found.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)Input schema defining the parameters iframeSelector and selector as required strings for identifying the iframe and element to 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:487-488 (registration)In the main tool handler switch statement, calls the execute method of the pre-instantiated iframeClickTool instance.case "playwright_iframe_click": return await iframeClickTool.execute(args, context);
- src/toolHandler.ts:322-322 (registration)Instantiation of the IframeClickTool instance during tool initialization in handleToolCall.if (!iframeClickTool) iframeClickTool = new IframeClickTool(server);
- src/toolHandler.ts:24-24 (registration)Import of IframeClickTool from './tools/browser/interaction.js'.IframeClickTool,