I cannot get access to the 2nd page by using phantomjs automation showing an error TypeError: undefined is not an object (evaluating 'r[20].click') undefined:7 :8
while running the phantomjs code
console.log("got here");
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open(url, function(status) {
if ( status === "success" ) {
page.evaluate(function() {
document.getElementById("txtLoginName").value = "safvan";
document.getElementById("txtPassword").value = "safvan542";
document.forms["logInForm"].submit();
console.log("Login submitted!");
var r=document.getElementsByTagName("a");
r[20].click();
});
window.setTimeout(function () {
page.render('hrtesttime.pdf');
phantom.exit();
}, 15000);
}
});