browser_select_checkbox
Select checkboxes in web browsers using Selenium WebDriver. Specify element locator strategy and value to automate checkbox interactions for testing and automation workflows.
Instructions
Select a checkbox
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | Yes | Locator strategy to find element | |
| value | Yes | Value for the locator strategy | |
| timeout | No | Maximum time to wait for element in milliseconds |
Implementation Reference
- src/tools/actionTools.ts:378-396 (registration)MCP tool registration for 'browser_select_checkbox' including inline handler that delegates to ActionService.selectCheckboxserver.tool('browser_select_checkbox', 'Select a checkbox', { ...locatorSchema }, async ({ by, value }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.selectCheckbox({ by, value }); return { content: [{ type: 'text', text: `Selected checkbox` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error selecting checkbox: ${(e as Error).message}`, }, ], }; } });
- src/services/actionService.ts:109-115 (handler)Core implementation logic: locates the checkbox element and clicks it if not already selectedasync selectCheckbox(params: LocatorParams): Promise<void> { const locator = LocatorFactory.createLocator(params.by, params.value); const checkbox = await this.driver.wait(until.elementLocated(locator), params.timeout || 15000); if (!(await checkbox.isSelected())) { await checkbox.click(); } }
- src/types/index.ts:29-35 (schema)Zod schema defining input parameters (locator strategy, value, optional timeout) for the toolexport const locatorSchema = { by: z .enum(['id', 'css', 'xpath', 'name', 'tag', 'class', 'link', 'partialLink']) .describe('Locator strategy to find element'), value: z.string().describe('Value for the locator strategy'), timeout: z.number().optional().describe('Maximum time to wait for element in milliseconds'), };
- src/tools/index.ts:8-13 (registration)Top-level tool registration function that invokes registerActionTools, including browser_select_checkboxexport function registerAllTools(server: McpServer, stateManager: StateManager): void { registerBrowserTools(server, stateManager); registerElementTools(server, stateManager); registerActionTools(server, stateManager); registerCookieTools(server, stateManager); }