Skip to content
Advertisement

Tag: puppeteer

Puppeteer can’t find elements when Headless TRUE

I’m facing some problems with Puppeteer, I want to extract a list of items and succeed when headless is FALSE but not when TRUE. First thing first, I want to get those elements before mapping on it. Here’s my script, maybe you can reproduce it, it is really basic. Answer For starters, I’d prefer page.waitForSelector(yourSelector) over page.waitForNetworkIdle();. In most cases,

Loop through pages to return all the product links

The goal is to obtain all product links from all pages in the pagination. So far I have managed to print information to the console with console.log (links). However, since I am completely new to this field and completely inexperienced, I have a problem how to pass some value back with the return command. return links. With console.log(links) I get

Get dataset object from an element in Puppeteer

Say i have this element: I’d like to get the data attributes via dataset. I can use the code below to get an individual data attribute, but if i want to get both data-* attributes, i’d have to scrape twice. I’ve tried this, but returns an empty object Answer Managed to accomplish it with this, but still very open to

Filtering files in directory with regex.match using Puppeteer

I’m having issues with regex.match not matching filenames which do match when I test them individually in an online checker https://regex101.com Can anyone spot the problem in code below? Q: Should I be using regex.test instead of match? If yes, how do I create the regex when it contains variables? It should match all files starting with: ES_(Stay) True –

scrollIntoView() looping element on puppeteer

I want to scrape a list of posts while the page scroll is infinite loading. I want scrollIntoView() for each element in the loop. my code is temporarily like this and the result when the page is loaded, it bounces out but no error. For example, I want to take 20 posts and then the scraper will take the posts

Puppeteer not picking up dialog box

I’m trying to test for an alert box in Puppeteer: However, it doesn’t seem to return the message inside the alert box (even though I’ve confirmed it works doing it manually). Any ideas why page.on(‘dialog’, async dialog => { isn’t being entered? Answer I’m not sure what’s going on with your page — it looks like you’re testing XSS, but

How to click and hold in Puppeteer

I am trying to click and hold using Puppeteer. I tried using page.click inside a while loop but it didn’t work. I also tried this: Any ideas how to do this? Answer There are a few tools to trigger a mouse hold in Puppeteer: page.click, mouse.click, mouse.down and mouse.up. page.hover can be useful for positioning the mouse over a selector

Advertisement