I am trying to auto click a button on a page using code in a .js file. The button I want to click is:
<input type="submit" class="btn btn-primary" value="Proceed to contract form">
Here is the javascript I am executing:
$(document).ready(function () {
console.log(document.getElementsByClassName('btn btn-primary')[0].type);
$('.btn btn-primary').click();
});
The message pops up properly in console. I have also tried window.onload to no avail, and also tried document.getElementsByClassName('btn btn-primary')[0].click; Nothing I try seems to work and I am at a loss. I even tried putting in a delay prior to executing the click, but that did not help either.
Thanks in advance for the advice and your patience with a Javascript newcomer (I have about 300 lines of working code after first starting to learn about 2 weeks ago... fun!).