public static WebElement findElementOrFail ( WebDriver webDriver , By element ) { try { return webDriver . findElement ( element ) ; } catch ( NoSuchElementException e ) { fail ( String . format ( "Element %s should exist but it does not." , element . toString ( ) ) , e ) ; } /** * Never reached since {@link de.codecentric.zucchini.bdd.util.Assert#fail(String)} fail()} throws * {@link java.lang.AssertionError}. */ return null ; }
Tries to find a specific element and fails if the element could not be found .