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 )

 

ENTER SOL CASINO

 


 

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 )

 

ENTER FRESH CASINO

 


 

 

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 )

 

OPEN JET CASINO

 


 

 

 

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 page.click, 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(‘https://br.betano.com/login/’) await delay(1000) await page.keyboard.type(‘*******’) await page.keyboard.press(‘Tab’) await page.keyboard.type(‘******’) await page.keyboard.press(‘Enter’) await delay(5000) await page.goto(‘https://br.betano.com/casino/live/games/roleta-brasileira/444/tables/103910/’) await delay(2000) await page.keyboard.press(‘Escape’) await delay(10000) await page.waitForSelector(‘[class=»header__more-games»]’) await page.click(‘[class=»header__more-games»]’)
catch(err) console.error(err)
)();

asked Apr 7, 2022 at 4:21

José Otavio's user avatar

4

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 page.click(‘[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»);
await buttonClick.click();

answered Apr 7, 2022 at 6:43

MC Naveen's user avatar

MC NaveenMC Naveen

4205 silver badges17 bronze badges

3

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(‘https://cachedownload-br.p-content.gambling-malta.com/live/?tableId=103910&game=rol&preferedmode=real&language=pt-br&advertiser=ptt/&clienttype=casino’) await page2.bringToFront() await delay(15000) const [button] = await page2.$x(«//button[contains(., ‘Ok’)]»); if (button) await button.click();

Tyler2P's user avatar

Tyler2P

2,28119 gold badges23 silver badges29 bronze badges

answered Apr 7, 2022 at 17:18

José Otavio's user avatar