Playwright · Middle · Question 41 of 75
What does page.evaluate() do?
const width = await page.evaluate(() => window.innerWidth);- 1Checks the page for JavaScript syntax errors
- 2Evaluates how fast the page scripts run
- 3Runs a function in the page and returns the result
Show the answer
Correct answer: Runs a function in the page and returns the result
Explanation
The function runs in the browser, so it can't use test variables unless passed as an argument. Results must be serializable.