【发布时间】:2015-05-14 07:16:52
【问题描述】:
我可以通过在量角器中使用element.all(by.repeater()) 并使用每个来检查匹配的文本来查找文本。现在,一旦匹配完成并单击匹配的元素,问题就会退出。
我尝试使用.each(),但无法退出迭代。
有什么建议吗?
【问题讨论】:
标签: javascript testing selenium protractor end-to-end
我可以通过在量角器中使用element.all(by.repeater()) 并使用每个来检查匹配的文本来查找文本。现在,一旦匹配完成并单击匹配的元素,问题就会退出。
我尝试使用.each(),但无法退出迭代。
有什么建议吗?
【问题讨论】:
标签: javascript testing selenium protractor end-to-end
在这种情况下,each() 不是一个好的选择。 听起来真的很像filtering,例如:
element.all(by.repeater("test in tests")).filter(function (elm) {
return elm.getText().then(function (text) {
return text === "Desired text";
});
}).then(function(filteredElements) {
filteredElements[0].click();
});
【讨论】: