How can I create a list of all 100 search engine result weblinks and then use a random number generator to click on one randomly?
Here is the code I've been working with that doesn't seem to be functioning properly:
for (var iterate=1; iterate<100;){
var randomnumber=Math.floor(Math.random()*4);
var i = randomnumber + 1;
console.log("Random Number generated for iteration " + iterate+ " is: "+i);
var link=element.all(by.tagName("a"));
browser.sleep(3000).then(function(){ console.log('Applied sleep for sometime');});
link.map(function(links){
return links;
}).then(function(links){
links[i].click();
})
Any advice or suggestions would be greatly appreciated.