asked 133k views
4 votes
How to handle dropdown in playwright?

1 Answer

4 votes

Final answer:

Playwright provides a method called 'selectOption' to handle dropdown menus. This method allows you to select options based on their value or label.

Step-by-step explanation:

In Playwright, you can handle dropdown menus using the selectOption method. This method allows you to select an option from a dropdown based on its value or label. Here's an example:

// Selecting an option by value
await page.selectOption('select[name=dropdown]', 'option1');

// Selecting an option by label
await page.selectOption('select[name=dropdown]', { label: 'Option 2' });

answered
User Dstj
by
7.5k points

Related questions

asked Jan 6, 2024 131k views
Bruce Patin asked Jan 6, 2024
by Bruce Patin
8.6k points
1 answer
2 votes
131k views