过滤ElementsCollection [英] Filtering an ElementsCollection
本文介绍了过滤ElementsCollection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个过滤ElementsCollection
的函数,其条件是每个元素的子元素(而不是元素本身)都有条件.
I'm trying to create a function to filter an ElementsCollection
, with a condition on a child of each element instead of the element itself.
这是我想出的:
public static ElementsCollection filterByChild(ElementsCollection elementsCollection, String childCssSelector,
Condition condition) {
Predicate<SelenideElement> childHasConditionPredicate = element -> element.$(childCssSelector).has(condition);
elementsCollection.removeIf(childHasConditionPredicate);
return elementsCollection;
}
当这样调用此函数时:
myCollection = SelenideHelpers.filterByChild(myCollection, "a", Condition.text("http://www.link.com");
我收到以下错误消息:
java.lang.UnsupportedOperationException: Cannot remove elements from web page
我在此错误消息上找不到任何可应用于我的代码的相关信息.我想知道为什么会出现此消息.
I did not found any relevant informations on this error message that could be applied to my code. I would like to know why is this message appearing.
推荐答案
查看全文