Basically, I'm trying to write a command-line client-side script (javascript) for purchasing something online automatically.
The problem is that on this particular webpage the button I'm trying to click (add to cart) appears several times in the page (for different products).
I know that:
document.getElementById('addToCart').submit();
will click on addToCart, but since there are several buttons with that same name how can I find and click on the specific button for a certain product?
We can assume that we know the product name in advance and that each addToCart button has a unique id (which I don't know).
addToCartyour webpage is broken. Ids must be unique within a document.