One of the challenges I am facing involves a webpage with multiple submit buttons. My goal is to iterate through each button and click on them one by one.
While I am aware that this can be achieved using xpath like this (//button[@class='submit'])[i]
(where i = loop number).
I'm curious if it's possible to do so via CSS selector as well?
I attempted button.submit
, but it always interacts with the first button, whereas I aim to cycle through all of them. I also experimented with button.submit:first-child
, but experienced similar results.
The HTML structure resembles the following:
<div>
<button class="submit" type="button"></button>
</div>
<div>
<button class="submit" type="button"></button>
</div>
<div>
<button class="submit" type="button"></button>
</div>