Skip to main content
Glama
raymondsambur

Automation Script Generator MCP Server

generate_page_file

Creates WDIO page object files with element selectors and functions to structure automated test scenarios for web applications.

Instructions

Generate WDIO page object file with general functions and element selectors

Input Schema

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

Implementation Reference

  • index.js:238-267 (registration)
    Tool registration configuration including name, description, and input schema validation for generate_page_file
    { 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, }, },
  • Main handler function for the generate_page_file tool: destructures args, calls buildPageFileContent to generate code, ensures directory exists, writes file to output_path, returns confirmation with 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}`); } }
  • Helper function that generates the complete page object JavaScript code: creates class name, generates selector getter methods and page action methods, formats as string with JSDoc
    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}; `; }
  • Helper that generates getter methods for page selectors from selectors object
    return Object.keys(selectors).map(key => { return ` get ${this.toCamelCase(key)}() { return $('${selectors[key]}'); }`; }).join('\n\n'); }
  • Helper that generates async page action methods from list of page_functions
    generatePageMethods(page_functions) { return page_functions.map(func => { const methodName = this.toCamelCase(func); return ` async ${methodName}() { ${this.generatePageMethodImplementation(func, methodName)} }`; }).join('\n\n'); }

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