register_custom_commands
Registers custom WebDriverIO commands with Playwright equivalents to handle project-specific functionality during test migration.
Instructions
Registers custom WDIO commands with their Playwright equivalents for migration. Allows handling project-specific custom commands.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commands | Yes | JSON string of custom command mappings: { "customCommand": { "method": "playwrightMethod", "description": "..." } } |
Implementation Reference
- src/handlers/toolHandlers.js:394-433 (handler)The handler function that executes the registration logic for custom commands by updating the COMMAND_MAPPINGS constant.
export async function handleRegisterCustomCommands(args) { const { commands } = args; let customCommands = {}; try { customCommands = JSON.parse(commands); } catch (e) { return { content: [{ type: 'text', text: 'Error: commands must be a valid JSON object', }], isError: true, }; } const addedCommands = []; for (const [wdioCmd, mapping] of Object.entries(customCommands)) { if (!COMMAND_MAPPINGS[wdioCmd]) { COMMAND_MAPPINGS[wdioCmd] = mapping; addedCommands.push(wdioCmd); } } return { content: [{ type: 'text', text: `# Custom Commands Registered ## Added Commands: ${addedCommands.length > 0 ? addedCommands.map(cmd => `- ${cmd} → ${COMMAND_MAPPINGS[cmd].method}`).join('\n') : 'No new commands added (already exist)'} ## Total Command Mappings: ${Object.keys(COMMAND_MAPPINGS).length} ## Usage: These commands will now be automatically migrated when using \`migrate_to_playwright\`. `, }], }; } - src/handlers/tools.js:135-147 (schema)The MCP tool definition for 'register_custom_commands', including its input schema.
name: 'register_custom_commands', description: 'Registers custom WDIO commands with their Playwright equivalents for migration. Allows handling project-specific custom commands.', inputSchema: { type: 'object', properties: { commands: { type: 'string', description: 'JSON string of custom command mappings: { "customCommand": { "method": "playwrightMethod", "description": "..." } }', }, }, required: ['commands'], }, },