3

我已将所有链接元素存储在 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 中的链接

4

1 回答 1

2

Protractor API 提供了每个迭代 ElementArrayFinder 和迭代 ElementFinder 对象

element.all(locator).each(eachFunction)

在 ElementArrayFinder 表示的每个 ElementFinder 上调用输入函数。

你可以做这样的事情

allLinks.each(function(link){
        link.click();
        //Do some validations you want to do on the new opened link
        browser.navigate().back();
    })
于 2017-03-05T09:19:11.160 回答