src/main/java/com/xceptance/neodymium/util/SelenideAddons.java
/**
     * The missing wrapper to generate screenshots and save the html source code if a jUnit assertion fails.<br>
     * <br>
     * <p>
     * Sample: Assert that page title is correct and dump the page source and a screenshot in case of a mismatch
     * <code> wrapAssertionError(()-&gt;{Assert.assertEquals("MyPageTitle", Selenide.title());});</code>
     * </p>
     * 
     * @param runnable
     *            The lambda containing an assertion
     */
The missing wrapper to generate screenshots and save the html source code if a jUnit assertion fails.


Sample: Assert that page title is correct and dump the page source and a screenshot in case of a mismatch
wrapAssertionError(()->{Assert.assertEquals("MyPageTitle", Selenide.title());});


@param runnable
The lambda containing an assertion
The missing wrapper to generate screenshots and save the html source code if a jUnit assertion fails . Sample : Assert that page title is correct and dump the page source and a screenshot in case of a mismatch wrapAssertionError (( ) - > { Assert . assertEquals ( " MyPageTitle " Selenide . title () ) ; } ) ; @param runnable The lambda containing an assertion
public static void wrapAssertionError(final Runnable runnable)
    {
        try
        {
            runnable.run();
        }
        catch (AssertionError e)
        {
            Driver driver = WebDriverRunner.driver();
            String message = "No error message provided by the Assertion.";
            if (StringUtils.isNotBlank(e.getMessage()))
            {
                message = e.getMessage();
            }
            else
            {
                AssertionError wrapper = new AssertionError(message, e.getCause());
                wrapper.setStackTrace(e.getStackTrace());
                e = wrapper;
            }
            SelenideLogger.commitStep(SelenideLogger.beginStep("Assertion error", message), e);
            if (!driver.config().assertionMode().equals(AssertionMode.SOFT))
            {
                throw UIAssertionError.wrap(driver, e, 0);
            }
        }
    }
public static void wrapAssertionError ( final Runnable runnable ) { try { runnable . run ( ) ; } catch ( AssertionError e ) { Driver driver = WebDriverRunner . driver ( ) ; String message = "No error message provided by the Assertion." ; if ( StringUtils . isNotBlank ( e . getMessage ( ) ) ) { message = e . getMessage ( ) ; } else { AssertionError wrapper = new AssertionError ( message , e . getCause ( ) ) ; wrapper . setStackTrace ( e . getStackTrace ( ) ) ; e = wrapper ; } SelenideLogger . commitStep ( SelenideLogger . beginStep ( "Assertion error" , message ) , e ) ; if ( ! driver . config ( ) . assertionMode ( ) . equals ( AssertionMode . SOFT ) ) { throw UIAssertionError . wrap ( driver , e , 0 ) ; } } }
The missing wrapper to generate screenshots and save the html source code if a jUnit assertion fails.<br>
 <br>
 <p>
 Sample: Assert that page title is correct and dump the page source and a screenshot in case of a mismatch
 <code> wrapAssertionError(()-&gt;{Assert.assertEquals("MyPageTitle", Selenide.title());});</code>
 </p>
The missing wrapper to generate screenshots and save the html source code if a jUnit assertion fails . <br > <br > <p > Sample : Assert that page title is correct and dump the page source and a screenshot in case of a mismatch <code > wrapAssertionError (( ) - &gt ; { Assert . assertEquals ( " MyPageTitle " Selenide . title () ) ; } ) ; < / code > < / p >