browser_unselect_checkbox
Unselect a checkbox in a web browser by specifying a locator strategy and value, enabling automation of form interactions and UI testing.
Instructions
Unselect 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:398-416 (handler)Handler function for the browser_unselect_checkbox tool, which locates the checkbox using ActionService and unselects it if selected.server.tool('browser_unselect_checkbox', 'Unselect a checkbox', { ...locatorSchema }, async ({ by, value }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.unselectCheckbox({ by, value }); return { content: [{ type: 'text', text: `Unselected checkbox` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error unselecting checkbox: ${(e as Error).message}`, }, ], }; } });
- Core implementation of unselecting a checkbox: waits for the element, checks if selected, and clicks to toggle off.async unselectCheckbox(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 definition for locator parameters (by, value, timeout) used in the tool input.export 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'), };