Playwright · Middle · Question 67 of 75

How do you handle a cookie consent banner that appears randomly?

Show the answer

Correct answer: Use page.addLocatorHandler to close it when it appears

Explanation

A locator handler runs whenever the overlay blocks an action, then the action continues. Setting a consent cookie up front is another option.

Further reading

Problem with a question

Playwright · Middle · question 67

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