Convert String to Proper or Title case

public static String toTitleCase(String input) { final String ACTIONABLE_DELIMITERS = ” ‘-/”; // these cause the character following // to be capitalized StringBuilder sb = new StringBuilder(); boolean capNext = true; for (char c : input.toCharArray()) { c = (capNext) ? Character.toUpperCase(c) : Character.toLowerCase(c); sb.append(c); capNext = (ACTIONABLE_DELIMITERS.indexOf((int) c) >= 0); // explicit cast not […]

Webdriver FluentWait

public Wait wait; WebDriver driver = new FirefoxDriver(); wait = new FluentWait(driver) .withTimeout(360, TimeUnit.SECONDS) .pollingEvery(5, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class); public WebElement fluentWait(final By locator) { WebElement foo = wait.until( new Function() { public WebElement apply(WebDriver driver) { return driver.findElement(locator); } } ); return foo; } public WebElement webElement(final By by) { return wait.until(ExpectedConditions.presenceOfElementLocated(by)); } public WebElement webElementVisible(final […]

checkCondition

public void checkCondition(boolean condition, String message) throws IOException { try { assertTrue(condition); System.out.println(message); } catch (AssertionError e) { message = message.contains(“is displayed”) ? message.replace(“is displayed”, “is not displayed”) : message.contains(“is disabled”) ? message.replace(“is disabled”, “is not disabled”) : message.contains(“is enabled”) ? message.replace(“is enabled”, “is not enabled”) : message.contains(“is not enabled”) ? message.replace(“is not enabled”, “is […]