Skip to main content
Glama

playwright_test_ui

Execute automated UI tests using Playwright to validate web application functionality across multiple browsers. Specify URL, test actions, and assertions to verify user interface behavior.

Instructions

Run UI tests with Playwright

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
testsYes
browsersNo

Implementation Reference

  • Core handler function that parses input, launches Playwright browsers, executes test actions and assertions, collects results across browsers.
    async testUI(args: any) {
      const params = PlaywrightTestSchema.parse(args);
      const results: any = {
        url: params.url,
        tests: [],
        summary: {
          passed: 0,
          failed: 0,
          total: params.tests.length
        }
      };
    
      try {
        for (const browserName of params.browsers) {
          const browser = await this.getBrowser(browserName);
          const page = await browser.newPage();
    
          try {
            await page.goto(params.url);
    
            for (const test of params.tests) {
              const testResult: any = {
                name: test.name,
                browser: browserName,
                passed: true,
                errors: []
              };
    
              try {
                // Execute actions
                for (const action of test.actions) {
                  await this.executeAction(page, action);
                }
    
                // Run assertions
                for (const assertion of test.assertions) {
                  await this.runAssertion(page, assertion);
                }
    
                results.summary.passed++;
              } catch (error: any) {
                testResult.passed = false;
                testResult.errors.push(error.message);
                results.summary.failed++;
              }
    
              results.tests.push(testResult);
            }
          } finally {
            await page.close();
          }
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(results, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: `Error running UI tests: ${error.message}`
            }
          ],
          isError: true
        };
      } finally {
        await this.closeBrowsers();
      }
    }
  • Input schema definition for the playwright_test_ui tool, registered in the ListTools response.
    {
      name: 'playwright_test_ui',
      description: 'Run UI tests with Playwright',
      inputSchema: {
        type: 'object',
        properties: {
          url: { type: 'string' },
          tests: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                name: { type: 'string' },
                actions: { type: 'array' },
                assertions: { type: 'array' }
              }
            }
          },
          browsers: {
            type: 'array',
            items: { 
              type: 'string',
              enum: ['chromium', 'firefox', 'webkit']
            },
            default: ['chromium']
          }
        },
        required: ['url', 'tests']
      }
    },
  • src/index.ts:320-323 (registration)
    Switch case registration that dispatches calls to the playwright_test_ui handler in PlaywrightTools.testUI.
    case 'playwright_test_ui':
      return await this.playwrightTools.testUI(args);
    case 'playwright_capture_screenshots':
      return await this.playwrightTools.captureScreenshots(args);
  • Zod validation schema used internally in the handler for parsing and validating tool arguments.
    const PlaywrightTestSchema = z.object({
      url: z.string().url(),
      tests: z.array(z.object({
        name: z.string(),
        actions: z.array(z.any()),
        assertions: z.array(z.any())
      })),
      browsers: z.array(z.enum(['chromium', 'firefox', 'webkit'])).default(['chromium'])
    });
  • Helper function to execute individual test actions such as click, fill, hover, wait, scroll.
    private async executeAction(page: Page, action: any): Promise<void> {
      switch (action.type) {
        case 'click':
          await page.click(action.selector);
          break;
        case 'fill':
          await page.fill(action.selector, action.value);
          break;
        case 'select':
          await page.selectOption(action.selector, action.value);
          break;
        case 'hover':
          await page.hover(action.selector);
          break;
        case 'wait':
          if (action.selector) {
            await page.waitForSelector(action.selector);
          } else {
            await page.waitForTimeout(action.timeout || 1000);
          }
          break;
        case 'scroll':
          await page.evaluate((scrollPosition) => {
            window.scrollTo(0, scrollPosition || document.body.scrollHeight);
          }, action.position);
          break;
        default:
          throw new Error(`Unknown action type: ${action.type}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Run UI tests' implies execution and potential side effects, but it doesn't describe what happens during testing (e.g., browser automation, network activity), whether it modifies systems, what output to expect, or error handling. This is inadequate for a tool with execution capabilities.

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 extremely concise with just four words, front-loading the core purpose without any wasted language. It's appropriately sized for a simple statement, though this brevity contributes to gaps in other dimensions.

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 the tool's complexity (3 parameters, execution behavior, no annotations, no output schema), the description is incomplete. It doesn't explain what the tool returns, how tests are structured, what 'actions' and 'assertions' arrays contain, or the execution environment. This leaves significant gaps for an AI agent to understand and use the tool effectively.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but fails to do so. It mentions no parameters at all, leaving 'url', 'tests', and 'browsers' completely unexplained. The description doesn't clarify what 'url' refers to, what 'tests' structure entails, or how 'browsers' affect execution.

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 'Run UI tests with Playwright' clearly states the action (run) and resource (UI tests) with the specific framework (Playwright). It distinguishes from siblings like 'playwright_capture_screenshots' by focusing on testing rather than screenshot capture. However, it doesn't fully differentiate from 'storybook_test_component' which might also involve UI testing.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose this over 'storybook_test_component' for component testing or 'playwright_capture_screenshots' for visual testing. There's no context about prerequisites, testing scenarios, or integration with other tools.

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/willem4130/ui-ux-mcp-server'

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