I have a situation where I use a protractor to click a random link on a page. (A lot of). I have an array of links that I donβt want to click, so I want to know when my random link is in this array and generates a new random link.
Here is my working code to click an arbitrary link on a page
var noClickArray = ['link2', 'link3']; // array much bigger than this var parent = this; function() { var links = element.all(by.css('.links')); return links.count().then(function(count) { var randomLink = links.get(Math.floor(Math.random() * count)); randomLink.getText().then(function(text) { parent.selectedLink = text; // used in a different function var containsLink = _.includes(noClickArray, text); }); return randomLink.click(); }); }
I use lodash to search if randomLink text is in noClickArray , but I don't know how to keep generating random values ββuntil the value exists in the array. How can i do this?
cocoa source share