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

JSHandle.evaluate doesn't pass itself as the first argument #1379

Closed
1 of 2 tasks
ankur22 opened this issue Jun 11, 2024 · 0 comments
Closed
1 of 2 tasks

JSHandle.evaluate doesn't pass itself as the first argument #1379

ankur22 opened this issue Jun 11, 2024 · 0 comments
Assignees
Labels
bug Something isn't working playwright Issue relating to Playwright compatibility

Comments

@ankur22
Copy link
Collaborator

ankur22 commented Jun 11, 2024

Brief summary

In Playwright, JSHandle.evaluate passes itself as the first argument: https://playwright.dev/docs/api/class-jshandle#js-handle-evaluate. k6 browser doesn't seem to do the same.

xk6-browser version

NA

OS

NA

Chrome version

NA

Docker version and image (if applicable)

NA

Steps to reproduce the problem

When calling the evaluate API like so:

  const page = await browser.newPage();

  await page.goto('https://test.k6.io/browser.php');
  const jsHandle = await page.evaluateHandle(() => document.body);

  const innerHTML = await jsHandle.evaluate((node) => node.innerHTML);

  console.log(innerHTML);

We get an error:

ERRO[0000] Uncaught (in promise) evaluating element: TypeError: Cannot read properties of undefined (reading 'innerHTML')
    at __xk6_browser_evaluation_script__:1:15  executor=shared-iterations scenario=browser

Expected behaviour

The expected bahaviour is that the innerHTML of the page's body is returned which can then be logged to the console.

Actual behaviour

ERRO[0000] Uncaught (in promise) evaluating element: TypeError: Cannot read properties of undefined (reading 'innerHTML')
    at __xk6_browser_evaluation_script__:1:15  executor=shared-iterations scenario=browser

Tasks

@ankur22 ankur22 added bug Something isn't working playwright Issue relating to Playwright compatibility labels Jun 11, 2024
@ankur22 ankur22 mentioned this issue Jun 11, 2024
3 tasks
@ankur22 ankur22 self-assigned this Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working playwright Issue relating to Playwright compatibility
Projects
None yet
Development

No branches or pull requests

2 participants