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.
Here's what I came up with:
public static ElementsCollection filterByChild(ElementsCollection elementsCollection, String childCssSelector,
Condition condition) {
Predicate<SelenideElement> childHasConditionPredicate = element -> element.$(childCssSelector).has(condition);
elementsCollection.removeIf(childHasConditionPredicate);
return elementsCollection;
}
When calling this function like this:
myCollection = SelenideHelpers.filterByChild(myCollection, "a", Condition.text("http://www.link.com");
I'm getting the following error message:
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.