How do i click in a div class using puppeteer?

Ratings and Reviews of Online Casinos


1. Sol Casino

Sol casino keyword

Free Sign-Up Bonus: 150 Free Spins ( Free Sign-Up Bonus Link )


First Deposit Bonus: 200% up to €/$ 500 ( Registration Link )





2. Fresh Casino

fresh casino

Free Sign-Up Bonus: 40 Free Spins ( Free Sign-Up Bonus Link )


First Deposit Bonus: 150% up to €/$ 1000 ( Registration Link )






3. Jet Casino

jet casino

Free Sign-Up Bonus: 200 Free Spins ( Free Sign-Up Bonus Link )


First Deposit Bonus: 200% up to €/$ 1000 ( Registration Link )







How do i click in a div class using puppeteer?

I’m trying to click in a button but i only have the class name, i’m trying to use, but never work so i try to add waitForSelector and always gives me time out, my code is very poor i’m just trying to learn more about to create new projects.

this is the item i’m trying to get

Also can be this item

const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
(async () => const browser = await puppeteer.launch( headless: false, product : «chrome», ); const page = await browser.newPage(); await page.setViewport( width:1920, height:1080 )
try await page.goto(‘’) await delay(1000) await page.keyboard.type(‘*******’) await‘Tab’) await page.keyboard.type(‘******’) await‘Enter’) await delay(5000) await page.goto(‘’) await delay(2000) await‘Escape’) await delay(10000) await page.waitForSelector(‘[class=»header__more-games»]’) await‘[class=»header__more-games»]’)
catch(err) console.error(err)

asked Apr 7, 2022 at 4:21

José Otavio's user avatar


You can always use the selector to select a particular element and click on it or you can also use Xpath.

Here is how you can get the Selector

  1. Right-click on the Element in Browser Devtools.
  2. Select Copy, then Copy Selector

enter image description here

Now, Replace these lines with the below one.

await page.waitForSelector(‘[class=»header__more-games»]’) await‘[class=»header__more-games»]’)

Make sure to replace the Your Selector Here with the actual selector you copied in the above steps.

await page.waitForSelector(‘Your Selector Here’); const buttonClick = await page.$(«Your Selector Here»);

answered Apr 7, 2022 at 6:43

MC Naveen's user avatar

MC NaveenMC Naveen

4205 silver badges17 bronze badges


I figure how to do it by using link in an iframe, in my case the link is always the same, so I just get the link and open in another tap. Like this:

await page2.goto(‘’) await page2.bringToFront() await delay(15000) const [button] = await page2.$x(«//button[contains(., ‘Ok’)]»); if (button) await;

Tyler2P's user avatar


2,28119 gold badges23 silver badges29 bronze badges

answered Apr 7, 2022 at 17:18

José Otavio's user avatar