Playwright · Junior · Question 29 of 75

How do you pick an option in a native <select>?

Show the answer

Correct answer: await locator.selectOption('blue')

Explanation

selectOption accepts a value, a label ({ label: 'Blue' }) or several values for a multi-select. Custom dropdowns are tested with clicks instead.

Further reading

Problem with a question

Playwright · Junior · question 29

Test yourself

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

Take this quiz