I'm trying to click programmatically a button from a web page using chrome console.
(UPDATED)The code of the button looks like this :
<FORM METHOD=GET ACTION="/xxx/yyy/kkk.jsp" >
<INPUT type="hidden" name="page" value="721">
<INPUT type="hidden" name="reqType" value="ReprintO">
<INPUT type="hidden" name="title" value="Reprint Label">
<INPUT type="hidden" name="system" value="reprint">
<td align=right width=25%><input type=submit value='>' name=BTN_CHOICE5/>
<td> Reprint Label
</form>
There are a couple more buttons on the page that have value= '>'
, so I guess I need to click it using name. I tried
document.querySelector('input[name="BTN_CHOICE4"]').click();
and it didn't work. How do I click this button using JS?
If you have ID attribute you can use
$('#btnId').click();
Or If you want to go by name, you can use
$('[name="someName"]').click();
But it would be good if you use by Id not by name as if multiple controls have same name attribute and value, then all those controls click event will be invoked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With