browser_submit_form
Automate form submission in web browsers using Selenium WebDriver. Specify element locator and value to submit forms programmatically for testing and automation workflows.
Instructions
Submit a form
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:418-436 (registration)Registration of the 'browser_submit_form' tool using server.tool, including inline handler that delegates to ActionService.submitForm and error handling.server.tool('browser_submit_form', 'Submit a form', { ...locatorSchema }, async ({ by, value }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.submitForm({ by, value }); return { content: [{ type: 'text', text: `Submitted form` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error submitting form: ${(e as Error).message}`, }, ], }; } });
- src/services/actionService.ts:91-95 (handler)Core handler logic in ActionService that locates the form using LocatorFactory and submits it using Selenium WebDriver's form.submit() method.async submitForm(params: LocatorParams): Promise<void> { const locator = LocatorFactory.createLocator(params.by, params.value); const form = await this.driver.wait(until.elementLocated(locator), params.timeout || 15000); await form.submit(); }
- src/types/index.ts:29-35 (schema)Zod schema defining the input parameters for locators (by, value, timeout), spread into the tool's input schema.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'), };