Playwright · Middle · Question 41 of 75

What does page.evaluate() do?

const width = await page.evaluate(() => window.innerWidth);
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.

Further reading

Problem with a question

Playwright · Middle · question 41

Test yourself

Take the Playwright · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz