0

I can't seem to find a solution. I'm able to click the modal, but once I target the id on something on the modal I get Node is either not clickable or not an HTMLElement. I'm using the below to target an id after the modal loads up from another click.

await page.click('#myid');
Jon
  • 453
  • 5
  • 18
  • 1
    Can you share the code before this statement (the code that opens the modal)? – Cave Johnson Sep 30 '21 at 16:19
  • The code is literally another click to click a button to load the modal. Same as posted, but different id. I can't seem to click any element on the modal once it loads. – Jon Sep 30 '21 at 16:21
  • 3
    do the modal contents happen to load asynchronously? I have a feeling that it doesn't wait for the contents to load before doing the click. As a sanity check you can try `await page.waitForTimeout(3000);` before the click. – Cave Johnson Sep 30 '21 at 16:26
  • Also, see https://stackoverflow.com/questions/46135853/puppeteer-how-to-wait-until-an-element-is-visible, you could try `page.waitForSelector('#myid')` – Cave Johnson Sep 30 '21 at 16:30
  • Yup. Thats it! I was pretty sure that I had set a timeout previously. Well, I did the waitForSelector. – Jon Sep 30 '21 at 16:31
  • see if `await page.waitForSelector('#myid')` works. That's probably more elegant. – Cave Johnson Sep 30 '21 at 16:31
  • The waitForSelector doesn't seem to work. However, the waitForTimeout does. Feel free to answer so I can mark it as the answer. Thanks for the help! – Jon Sep 30 '21 at 16:39
  • `waitForTimeout` is a race condition and very unlikely to be the optimal answer. Please share a [mcve] that shows the page you're scraping. Without it, it's sort of like trying to hit a target with the lights out. – ggorlen Sep 30 '21 at 17:01
  • @ggorlen agreed, I wasn't suggesting waitForTimeout was the solution, just to help determine the problem. – Cave Johnson Sep 30 '21 at 17:04
  • @Jon did you prefix `page.waitForSelector('#myid')` with `await`? – Cave Johnson Sep 30 '21 at 17:08
  • Yes. I tried waiting for the selector id for the modal and several different elements and for some reason it didn't work. The waitForTimeout did though. – Jon Oct 01 '21 at 12:00

0 Answers0