pilot_frame_select
Switch browser automation context to a specific iframe by index or name, enabling subsequent interactions like clicking and filling forms within that frame.
Instructions
Switch context to an iframe by index or name. After switching, pilot_snapshot/click/fill will operate inside that iframe. Use pilot_frames to list available frames.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | No | Frame index from pilot_frames output | |
| name | No | Frame name attribute |
Implementation Reference
- src/tools/iframe.ts:34-57 (handler)The handler implementation for the 'pilot_frame_select' tool, which takes an index or name to switch the browser context to a specific iframe.
server.tool( 'pilot_frame_select', 'Switch context to an iframe by index or name. After switching, pilot_snapshot/click/fill will operate inside that iframe. Use pilot_frames to list available frames.', { index: z.number().optional().describe('Frame index from pilot_frames output'), name: z.string().optional().describe('Frame name attribute'), }, async ({ index, name }) => { await bm.ensureBrowser(); try { if (index !== undefined) { const frame = bm.selectFrameByIndex(index); return { content: [{ type: 'text' as const, text: `Switched to frame ${index} (${frame.url()}). Refs cleared — run pilot_snapshot for fresh refs.` }] }; } if (name) { const frame = bm.selectFrameByName(name); return { content: [{ type: 'text' as const, text: `Switched to frame "${name}" (${frame.url()}). Refs cleared — run pilot_snapshot for fresh refs.` }] }; } return { content: [{ type: 'text' as const, text: 'Provide index or name. Use pilot_frames to list available frames.' }], isError: true }; } catch (err) { return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } );