我已经将所有链接元素存储在var中,如下所示:
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);
})
这部分工作正常,现在我要逐一导航到存储在var allLinks中的链接
最佳答案
Protractor API提供each来遍历ElementArrayFinder并与ElementFinder对象进行迭代
你可以做这样的事情
allLinks.each(function(link){
link.click();
//Do some validations you want to do on the new opened link
browser.navigate().back();
})