Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Provide convenience methods to find RNodes and Nodes that will fail if nothing is found. #22

Open
MarceloRuiz opened this issue Aug 22, 2017 · 0 comments

Comments

@MarceloRuiz
Copy link

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();
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant