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');
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions generating a file but doesn't disclose behavioral traits such as file overwriting behavior, error handling, required permissions, or output format. For a file generation tool with zero annotation coverage, this leaves significant gaps in understanding how it operates.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. Every word earns its place with no redundancy or unnecessary elaboration, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a tool that generates files (a potentially complex operation), the description is incomplete. It doesn't cover what the generated file contains beyond 'general functions and element selectors', error conditions, or how it integrates with other tools like 'process_test_scenario'. More context is needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 4 parameters thoroughly. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain how 'selectors' should be structured or what 'page_functions' entail). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool generates a WDIO page object file with functions and selectors, providing specific verb ('generate') and resource ('WDIO page object file'). It distinguishes from some siblings like 'generate_feature_file' or 'generate_steps_file' by specifying the file type, but doesn't explicitly differentiate from 'generate_component_file' which might be similar.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives like 'generate_component_file' or 'process_test_scenario'. The description implies usage for WDIO test automation but doesn't specify prerequisites, dependencies, or context for choosing this over other code generation tools in the sibling list.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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