Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: page evaluate returns undefined for a specific site #29440

Closed
reginaldl opened this issue Feb 9, 2024 · 5 comments
Closed

[Bug]: page evaluate returns undefined for a specific site #29440

reginaldl opened this issue Feb 9, 2024 · 5 comments

Comments

@reginaldl
Copy link

Version

1.41.2

Steps to reproduce

  1. Clone https://github.com/reginaldl/playwright-bug
  2. npm install
  3. npx playwright test

Expected behavior

page.evaluate should return 42.

Actual behavior

page.evaluate consistently returns undefined on all browsers.

Additional context

page.evaluate returns an unexpected value exclusively when browsing a specific website (see test case for exact address).

Environment

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 32.35 GB / 64.00 GB
  Binaries:
    Node: 21.4.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - /opt/homebrew/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.41.2 => 1.41.2
@reginaldl reginaldl changed the title [Bug]: page Evaluate undefined for a specific site [Bug]: page evaluate returns undefined for a specific site Feb 9, 2024
@dgozman
Copy link
Contributor

dgozman commented Feb 9, 2024

Investigation notes: this is due to window.eval being overwritten.

@ZooDoo4U
Copy link

ZooDoo4U commented Feb 12, 2024

There is a bug in the repro code...

Should be:
var res = await page.evaluate( async() => 41 + 1)

As you have it, you are evaluating a string?

Would suggest closing as by design...

@reginaldl
Copy link
Author

Have you actually tried replacing with a function? It also fails.
Given that the site overwrites window.eval, I'm ok closing this as won't fix.

@ZooDoo4U
Copy link

Yes, i did and it worked. But while i ran again my own site and the evaluate worked just fine. Can't help if a rouge site is overwriting stuff, not really a PW issue...

@mxschmitt
Copy link
Member

If a site is overriding globalThis.eval we unfortunately can't do much from the Playwright side. Closing as a won't fix.

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 a pull request may close this issue.

4 participants