Search code examples
javascriptbuttonpuppeteercart

How to make a click on a button that doesnt have id on pupeteer


I'm working on a bot that buy by himself, but after he put the Credit card, exp and cvv, the page has a button that doesn't have id, only have class, the code of the button is

<button type="submit" class="btn btn-primary btn-block submit_silentOrderPostForm checkout-next">Siguiente</button>

I'm trying with

await page.click('#btn btn-primary btn-block submit_silentOrderPostForm checkout-next')

and with

await page.click('btn btn-primary btn-block submit_silentOrderPostForm checkout-next')

but it doesn't work. How may I do it? Thanks


Solution

  • Page.click requires a CSS selector as its mandatory parameter. Do not forget that CSS class selector syntax is: .class-name, so you will need something like this:

    await page.click('.btn.btn-primary.btn-block.submit_silentOrderPostForm.checkout-next')