Skip to content

codegen problems #123

Open
Open
@anic

Description

@anic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions