我已将所有链接元素存储在 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 对象交互
element.all(locator).each(eachFunction)
Calls the input function on each ElementFinder represented by the ElementArrayFinder.
你可以这样做
allLinks.each(function(link){
link.click();
//Do some validations you want to do on the new opened link
browser.navigate().back();
})
关于javascript - 如何使用 Protractor 一一单击所有链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42606064/