pilot_select_option
Select dropdown options by value, label, or visible text in browser automation using element references or CSS selectors.
Instructions
Select a dropdown option by value, label, or visible text.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | Yes | Select element ref (@e3) or CSS selector | |
| value | Yes | Option value, label, or text to select |
Implementation Reference
- src/tools/interaction.ts:112-135 (handler)The implementation of the `pilot_select_option` tool, which uses `BrowserManager` to resolve the target element and Playwright's `selectOption` method to perform the selection.
server.tool( 'pilot_select_option', 'Select a dropdown option by value, label, or visible text.', { ref: z.string().describe('Select element ref (@e3) or CSS selector'), value: z.string().describe('Option value, label, or text to select'), }, async ({ ref, value }) => { await bm.ensureBrowser(); try { const resolved = await bm.resolveRef(ref); if ('locator' in resolved) { await resolved.locator.selectOption(value, { timeout: 5000 }); } else { await bm.getPage().selectOption(resolved.selector, value, { timeout: 5000 }); } bm.resetFailures(); return { content: [{ type: 'text' as const, text: `Selected "${value}" in ${ref}` }] }; } catch (err) { bm.incrementFailures(); return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } );