Having trouble with `await page.select` in Puppeteer? Need help with dropdown selection!

24 Replies, 2281 Views

Yo, I’ve been there! Sometimes `await page.select puppeteer` doesn’t work because the dropdown is inside a shadow DOM. If that’s the case, you’ll need to use `page.evaluate` to access it:

```javascript
await page.evaluate(() => {
const shadowRoot = document.querySelector('your-shadow-host').shadowRoot;
const dropdown = shadowRoot.querySelector('select#myDropdown');
dropdown.value = 'optionValue';
});
```

This bypasses the usual select method but gets the job done.

Messages In This Thread



Users browsing this thread: 1 Guest(s)