3

I have stored all the link elements in var as below-

it("should click all the links one by one", function() 
{
    browser.get("https://angularjs.org");
    var allLinks=element.all(by.tagName("a"));
    var number=allLinks.count();
    expect(number).toEqual(80);
})

This part is working fine, now I want to navigate to links stored in var allLinks one by one

Ajay Patil
  • 159
  • 1
  • 7

1 Answers1

2

Protractor API provides each to iterate over ElementArrayFinder and iteract with the ElementFinder objects

element.all(locator).each(eachFunction)

Calls the input function on each ElementFinder represented by the ElementArrayFinder.

You can do something like this

allLinks.each(function(link){
        link.click();
        //Do some validations you want to do on the new opened link
        browser.navigate().back();
    })
AdityaReddy
  • 3,625
  • 12
  • 25