I'm trying to click on next link on a html page but having difficulties.
I have to get elementbyclassname of the main div and clicking on the second element of the div, here is the HTML of page i want to click:
<div class="next-previous">
<a href="http://website.net/560339/1/">Previous </a>
<a href="http://website.net/560339/2/">Next</a>
</div>
Here is the Javascript what I have tried so far.
var nextlink = document.getElementsByClassName('next-previous');
nextlink[0].click();
<div>instead of the children<a>s? Do a.children[0]to get the top anchor.<a>var nextlink = document.getElementsByClassName('next-previous'); nextlink.children[0].click();