0

I have just started using the Puppeteer API and despite how deep I've looked, I can't find a solid solution to this error I'm having. Basically, I'm trying to focus an element that's a drop-down menu and select a value from it. Unfortunately, every solution I've tried, whether I got it from here or from another source, has not worked.

Here is a list of things I've tried:

How to select an option from dropdown select

Getting value from dropdown menu?

How can I select a dropdown option

Any help would be appreciated in this matter, it has been driving me up the wall and is the only thing holding me back from finishing my project.

EDIT: Here is my code so far, if it helps.

const puppeteer = require('puppeteer');
(async () => {
  const browser = await puppeteer.launch({headless: false});
  const page = await browser.newPage();
  await page.goto('[REDACTED]');
  //this is where the drop-down selection would take place
})();
Old Ice
  • 1
  • 5
  • It'd would be of great help if you can post your the relevant subset of your code, as it makes it a lot easier to reason about and debug :-) – tomahaug Oct 19 '17 at 12:57
  • @tomahug Please see my edit. – Old Ice Oct 19 '17 at 22:43
  • can you post proper question with adding webpage that represent the dropdown menu, instead just use `REDACTED`. – Adi Prasetyo Oct 21 '17 at 16:10
  • This is a bit hacky, but might work if JS is preventing the usual approaches from working. In the example below, try replacing 'menu' with appropriate selectors to target the menu you're interested. The down arrow will result in the next item being selected. You may also need to add a button press if the menu is part of a form with a submit button. await page.focus("menu"); await page.keyboard.press('ArrowDown'); – P.J Jun 03 '22 at 12:33
  • It's hard to help without seeing the page at all. All of the links you shared are the normal ways of doing this, so you'd have to provide more detail so we can understand what you tried exactly and what page you're working with. Voting to close as this is quite old. – ggorlen Dec 02 '22 at 20:01

0 Answers0