What I want to do is to click a button on a page using javascript, then wait for the next page to come up and then click another button. Earlier I was doing this:
document.getElementById("abc").click();
document.getElementById("def").click(); // I want this for page 2.
This didn't work because page 2 didn't get loaded by that time it reached the second line of code.
I got a work around for this by doing this:
document.getElementById("abc").click();
var t=setTimeout(function(){document.getElementById("def").click();},3000)
By putting a waiting time of 3 seconds. But I don't like my approach. This approach depends on the fact that the other page would get loaded by this time. Is there a better way to do this? Can I check whether page 2 was loaded and then perform the action?
Thanks