0

I would like to click a submit button with puppeteer. the only problem is that there are 2 submit buttons on the page with the same class. Both have no ID. But both have different text. So should I select the text? And do you have any idea how I can do it for myself?

<button type="submit" class="btn btn-info btn-lg btn-block">
          <span class="glyphicon glyphicon-ok" aria-hidden="true"></span> Submit
        </button>

<button type="submit" class="btn btn-default btn-block" formaction="https://www.example.de/" formmethod="get">
        <span class="glyphicon glyphicon-home" aria-hidden="true"></span> exit</button>
  • Well, up to you and hard for me to make a recommendation without any context about the parent tree. For starters, which button do you want to click? You can select the second by `[formaction]` or select the second nth-child (maybe) or nth of type. If you want the first, maybe just use a normal selector. You can also [How to click on element with text in Puppeteer](https://stackoverflow.com/questions/47407791/how-to-click-on-element-with-text-in-puppeteer) (I'm a bit partial to [this answer](https://stackoverflow.com/a/64626061/6243352) from that page) – ggorlen Sep 29 '22 at 16:30

0 Answers0