0

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

  • Does this answer your question? [How to click a button on a website using Puppeteer without any class, id ,... assigned to it?](https://stackoverflow.com/questions/52904802/how-to-click-a-button-on-a-website-using-puppeteer-without-any-class-id-as) – biberman Apr 09 '21 at 07:48

3 Answers3

1

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')
theDavidBarton
  • 7,643
  • 4
  • 24
  • 51
0

Add a unique class name like mybutton or whatever and add it to that button.

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

Call it like this:

 await page.click('mybutton')

I hope that gives you an idea.

0

You can identify the element with a query selector that checks as much info as you have, like this...

var B=document.querySelectorAll('button[type="submit"][class*="submit_silentOrderPostForm"]')[0];


B.style.color='red'; // It works! :)