I’m having trouble with my Puppeteer script. It’s crashing after a click event with this error:
TypeError: Promise.resolve is not a function
The script navigates to a URL, waits for an iframe, clicks some elements, and tries to upload a file. It works fine until it tries to wait for a table after clicking an element.
Here’s a simplified version of what I’m trying to do:
I’ve dealt with similar Puppeteer issues, and it seems like you might be facing a timing problem. Have you tried increasing the timeout for your waitForSelector calls? Sometimes the default timeout isn’t long enough, especially for dynamic content.
Also, consider using waitForNavigation after your clicks. This ensures the page has fully loaded before proceeding. Something like:
This approach has saved me countless headaches with Puppeteer scripts.
Lastly, make sure you’re closing your browser instance at the end of your script. Unclosed instances can sometimes lead to unexpected behavior in subsequent runs.
yo, i had similar probs with puppeteer. try using page.evaluate() instead of direct DOM manipulation. it’s way more reliable. also, check ur node version - older ones can mess with promises. if all else fails, try playwright. it’s like puppeteer on steroids lol. good luck!
I’ve encountered similar issues with Puppeteer before, and it sounds like you might be running into a race condition. One thing that helped me was adding more explicit waits, especially after clicks.
Try adding a small delay after each click, like this:
await button.click();
await page.waitForTimeout(1000); // Add a 1-second delay
Also, make sure you’re using the latest version of Puppeteer. Older versions sometimes had quirks with promise handling.
Another trick that worked for me was wrapping problematic operations in a try/catch block and retrying a few times. Sometimes network hiccups or slow page loads can cause these errors.
Lastly, double-check that you’re not accidentally overwriting the global Promise object somewhere in your code. That could explain the ‘Promise.resolve is not a function’ error.
Hope this helps! Let me know if you need more details on any of these suggestions.