Skip to content

Commit

Permalink
added new functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Pfotenhauer committed Apr 9, 2018
1 parent 2f732db commit 6874b64
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/java/com/xceptance/neodymium/util/SelenidePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,34 @@ public ElementsCollection get()
};
}

/**
* Returns an supplier that will return all results if any. It will return elements that are found by parentSelector
* and have a no result for subElementSelector. It does NOT return the subelements, it is meant to be a workaround
* for poor CSS where the parent is only recognizable by looking at its children, but we don't need the children.
* Important, this is meant to be lazy so don't call get() when you setup a field or so, only when you really need
* the element. It reselects all the time!
*
* @param parentSelector
* The selector that is used to find subElementSelector
* @param subElementSelector
* The selector that shall not be contained by the parentSelector
* @return an supplier that will return the result later
*/
public static Supplier<ElementsCollection> parentsWithoutSubElement(final By parentSelector, final By subElementSelector)
{
return new Supplier<ElementsCollection>()
{
@Override
public ElementsCollection get()
{
List<SelenideElement> list = $$(parentSelector).stream().filter(e -> {
return !e.$(subElementSelector).exists();
}).collect(Collectors.toList());
return new ElementsCollection(new WebElementsCollectionWrapper(list));
};
};
}

/**
* Re-execute the entire code when a stale element exception comes up
*
Expand Down

0 comments on commit 6874b64

Please sign in to comment.