How to select a dropdown using Puppeteer

You can select a dropdown using Puppeteer by following these steps:

First of all, find the element on the page using a DOM selector. You can use document.querySelector or page.$ to find the element.

const dropdown = await page.$('#dropdown');


Click on the element to open the dropdown menu. You can use the click method to do this.

await dropdown.click();


Find the option you want to select in the dropdown menu. You can use a DOM selector to find the option element.

const option = await page.$('#dropdown option[value="option-1"]');


Click on the option to select it. You can use the click method to do this.

await option.click();


If the dropdown menu closes automatically after an option is selected, you are done. If the dropdown menu stays open, you may need to click on the dropdown element again to close it.

await dropdown.click();



I hope this helps! Let me know if you have any questions.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.