单击具有相同 class 且与文本匹配的元素并退出 Protractor
Click on a element with same class that matches text and exit in Protractor
我可以通过在量角器中使用 element.all(by.repeater())
并使用每个来检查匹配的文本来找到文本。现在,一旦匹配完成并单击匹配的元素,问题就会退出。
我尝试使用 .each()
,但无法退出迭代。
有什么建议吗?
在这种情况下,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();
});
我可以通过在量角器中使用 element.all(by.repeater())
并使用每个来检查匹配的文本来找到文本。现在,一旦匹配完成并单击匹配的元素,问题就会退出。
我尝试使用 .each()
,但无法退出迭代。
有什么建议吗?
在这种情况下,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();
});