mcp-playwright icon indicating copy to clipboard operation
mcp-playwright copied to clipboard

codegen problems

Open anic opened this issue 7 months ago • 0 comments

I use mcp-playwright as a tool for llm (cline in Visual Studio Code as Agent),and I want it to generate all the code.

The get_codegen_session result as follows

{
  "id": "555c1441-4020-4b9e-8ee0-bf9530916169",
  "actions": [
    {
      "toolName": "playwright_navigate",
      "parameters": {
        "url": "https://www.bing.com",
        "browserType": "chromium"
      },
      "timestamp": 1746414790289
    },
    {
      "toolName": "playwright_fill",
      "parameters": {
        "selector": "input[name='q']",
        "value": "openai"
      },
      "timestamp": 1746414819051
    },
    {
      "toolName": "playwright_press_key",
      "parameters": {
        "key": "Enter",
        "selector": "#sb_form_q"
      },
      "timestamp": 1746414868003
    },
    {
      "toolName": "playwright_evaluate",
      "parameters": {
        "script": "document.querySelector('#b_results > li:nth-child(1) > h2 > a').href"
      },
      "timestamp": 1746414891677
    }
  ],
  "startTime": 1746414781503,
  "options": {
    "outputPath": "/somepath/src/generated.spec.js",
    "testNamePrefix": "BingSearchTest",
    "includeComments": true
  },
  "endTime": 1746415261364
}

the generated result is


import { test } from '@playwright/test';
import { expect } from '@playwright/test';

test('BingSearchTest_2025-05-05', async ({ page, context }) => {
  
    // Navigate to URL
    await page.goto('https://www.bing.com');

    // Fill input field
    await page.fill('input[name='q']', 'openai');

    // Fill input field
    await page.fill('#sb_form_q', 'openai');
});

the problems is 1 It didn't conform to the syntax of TypeScript ,such as await page.fill('input[name='q']', 'openai'); 2 It didn't generate all the step, suche as playwright_evaluate

Hope to fix it

anic avatar May 05 '25 03:05 anic