public static ExpectedCondition < Boolean > urlContains ( final String fraction ) { return new ExpectedCondition < Boolean > ( ) { private String currentUrl = "" ; @ Override public Boolean apply ( WebDriver driver ) { currentUrl = driver . getCurrentUrl ( ) ; return currentUrl != null && currentUrl . contains ( fraction ) ; } @ Override public String toString ( ) { return String . format ( "url to contain \"%s\". Current url: \"%s\"" , fraction , currentUrl ) ; } } ; }
An expectation for the URL of the current page to contain specific text .