Skip to content

[Bug]: Playwright compatibility - 'Too many arguments' error in forceChromeSelectRendering #1738

@xuanli

Description

@xuanli

Version

System:
  OS: Windows 11 / macOS 15.2
  Node: v20.x
Browsers:
  Chrome: 131.x
npmPackages:
  @midscene/web: 1.0.4
  playwright-core: 1.49.x

Details

When using Midscene with Playwright (not Puppeteer), the forceChromeSelectRendering function causes repeated console errors on every page load:

Midscene - Failed to add base-select appearance style: Error: Too many arguments. If you need to pass more than 1 argument to the function wrap them in an object.
    at assertMaxArguments (playwright-core/lib/client/jsHandle.js:101:11)
    at Page.evaluate (playwright-core/lib/client/page.js:395:44)
    at injectStyle (@midscene/web/dist/es/puppeteer/base-page.mjs:505:24)

Root cause: In base-page.ts line 748-756, the code passes multiple arguments to page.evaluate() using Puppeteer-style syntax:

await (page as PuppeteerPage & PlaywrightPage).evaluate(
  (id, content) => { ... },
  styleId,
  styleContent,
);

Puppeteer allows multiple arguments after the function, but Playwright requires wrapping them in an object.

Note: The BasePage.evaluate wrapper method (lines 80-99) handles single-arg correctly, but forceChromeSelectRendering bypasses it and calls directly on the page.

Reproduce link

https://github.com/web-infra-dev/midscene/blob/main/packages/web-integration/src/puppeteer/base-page.ts#L748-L756

Reproduce Steps

  1. Use Midscene with Playwright (not Puppeteer)
  2. Navigate to any page with forceChromeSelectRendering enabled
  3. Observe console error: "Too many arguments..."
  4. Error repeats on every page load event

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions