javascript - Given a list of links, how do I click and validate each one using C# or Protractor, with Selenium? -


code below in c#, know javascript/protractor. looking pattern works.

var links = driver.findelements(by.tagname("a"));            foreach (var ele in links) {      if (ele.displayed == false) continue;     if (ele.enabled) ele.click();       system.threading.thread.sleep(3000);     driver.navigate().back();     system.threading.thread.sleep(3000);  } 

without sleep above (which don't like) page hasn't settled down enough navigate back. sleep values in, can click link, , go 1 time! error on 2nd iteration tells me the page stale.

question: using selenium c# or protractor how go through entire list of links?

if these links regular links href attributes, can use map() array of hrefs, , navigate each of them 1 one. protractor-specific solution:

element.all(by.tagname("a")).map(function (a) {     return a.getattribute("href"); }).then(function (links) {     (i = 0; < links.length; i++) {          browser.get(links[i]);         // todo: logic here     } }); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -