Users can easily the Optional values when searching either for a Node or RNode and are forced to interact with the Optional value. Sometimes it might be useful to just fail the test when the expected element is not present.
Consider adding the following convenience methods like the following ones:
protected <T extends Node> T find(final String searchTerm) {
final Optional<RNode<T>> optional = rc().cssFirst(searchTerm);
if (!optional.isPresent()) {
fail("Unable to find Node with search term: '" + searchTerm + "'");
}
return optional.get().node();
}
protected <T extends Node> RNode<T> rNode(final String searchTerm) {
final Optional<RNode<T>> optional = rc().cssFirst(searchTerm);
if (!optional.isPresent()) {
fail("Unable to find RNode with search term: '" + searchTerm + "'");
}
return optional.get();
}