Skip to main content
Glama
raymondsambur

Automation Script Generator MCP Server

generate_page_file

Creates WDIO page object files by generating element selectors and predefined functions based on test scenarios, streamlining test automation setup for efficient script management.

Instructions

Generate WDIO page object file with general functions and element selectors

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
output_pathYesPath where the page file should be saved
page_functionsNoList of page functions needed
scenario_titleYesTitle of the test scenario
selectorsYesSelectors for each UI element

Implementation Reference

  • Primary execution handler for the generate_page_file tool. Destructures input arguments, invokes the buildPageFileContent helper to generate the page object code, ensures output directory exists, writes the file, and returns a success response with the generated content.
    async generatePageFile(args) { const { scenario_title, selectors, page_functions = [], output_path } = args; try { const pageContent = this.buildPageFileContent(scenario_title, selectors, page_functions); await fs.ensureDir(path.dirname(output_path)); await fs.writeFile(output_path, pageContent); return { content: [ { type: 'text', text: `Page file generated successfully at: ${output_path}\n\nContent:\n${pageContent}`, }, ], }; } catch (error) { throw new Error(`Failed to generate page file: ${error.message}`); }
  • Input schema definition for the generate_page_file tool, used for validation and MCP tool discovery. Defines required properties and structure for tool arguments.
    name: 'generate_page_file', description: 'Generate WDIO page object file with general functions and element selectors', inputSchema: { type: 'object', properties: { scenario_title: { type: 'string', description: 'Title of the test scenario', minLength: 1, }, selectors: { type: 'object', description: 'Selectors for each UI element', }, page_functions: { type: 'array', items: { type: 'string' }, description: 'List of page functions needed', }, output_path: { type: 'string', description: 'Path where the page file should be saved', minLength: 1, }, }, required: ['scenario_title', 'selectors', 'output_path'], additionalProperties: false, },
  • index.js:330-334 (registration)
    Registration of the ListTools endpoint that exposes the generate_page_file tool (via toolConfigs array) to MCP clients listing available tools.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolConfigs, }; });
  • index.js:352-353 (registration)
    Dispatch registration in CallToolRequestSchema handler's switch statement that routes calls to the generate_page_file tool to its handler function.
    case 'generate_page_file': return await this.generatePageFile(args);
  • Key helper method that constructs the complete WDIO page object JavaScript file content, including JSDoc, class definition, selector getters (via generateSelectorMethods), page methods (via generatePageMethods), and module export.
    buildPageFileContent(scenario_title, selectors, page_functions) { const className = this.toPascalCase(scenario_title.replace(/[^a-zA-Z0-9]/g, '')) + 'Page'; const selectorMethods = this.generateSelectorMethods(selectors); const pageMethods = this.generatePageMethods(page_functions); return `/** * Page Object Model for ${scenario_title} * Contains selectors and page-specific functions */ class ${className} { // Element selectors ${selectorMethods} // Page functions ${pageMethods} } module.exports = ${className}; `;

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/raymondsambur/automation-script-generator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server