Skip to content

fix: PlaywrightAdapter.evaluateOnPage() spread multiple arguments correctly#16

Merged
konard merged 4 commits intomainfrom
issue-15-85e23cad40a2
Jan 9, 2026
Merged

fix: PlaywrightAdapter.evaluateOnPage() spread multiple arguments correctly#16
konard merged 4 commits intomainfrom
issue-15-85e23cad40a2

Conversation

@konard
Copy link
Member

@konard konard commented Jan 8, 2026

Summary

Fixes PlaywrightAdapter.evaluateOnPage() to correctly spread multiple arguments to the function in the browser context, matching Puppeteer's behavior.

Root Cause:
Playwright's page.evaluate() only accepts a single argument. When multiple args are passed, the function was receiving the entire array as its first parameter instead of spread arguments.

Solution:
When multiple arguments are passed, the fix:

  1. Serializes the function to a string
  2. Passes both function string and args array as a single object to page.evaluate()
  3. Reconstructs and calls the function with spread arguments in the browser context

Changes

  • Fixed PlaywrightAdapter.evaluateOnPage() to spread multiple arguments correctly
  • Updated mock to accurately simulate Playwright's single-argument behavior
  • Added unit tests for zero, single, and multiple argument scenarios
  • Added test for the real-world bug case (selector + array)

Test Plan

  • All 365 unit tests pass
  • Lint passes (0 errors, pre-existing warnings only)
  • CI pipeline passes

Fixes #15

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #15
@konard konard self-assigned this Jan 8, 2026
konard and others added 2 commits January 8, 2026 23:50
…rectly

When multiple arguments are passed to evaluateOnPage(), they are now
properly spread to the function in the browser context, matching
Puppeteer's behavior.

The fix wraps the function and passes args as a single object with
fnStr and argsArray, then reconstructs and calls the function with
spread arguments in the browser context.

Fixes #15

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] PlaywrightAdapter.evaluateOnPage() incorrectly passes multiple arguments to page.evaluate() fix: PlaywrightAdapter.evaluateOnPage() spread multiple arguments correctly Jan 8, 2026
@konard konard marked this pull request as ready for review January 8, 2026 22:54
@konard
Copy link
Member Author

konard commented Jan 8, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.028449 USD
  • Calculated by Anthropic: $2.684432 USD
  • Difference: $-1.344017 (-33.36%)
    📎 Log file uploaded as GitHub Gist (540KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 63af079 into main Jan 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PlaywrightAdapter.evaluateOnPage() incorrectly passes multiple arguments to page.evaluate()

1 participant