demoiselle/behave — pull request #225 by rogernobre (2014-05-28 20:37:41+00:00)
Title: Retirada da verificação de visibilidade

A chamada "waitVisibility(by);" está sendo desnecessária, isto é, o método "elementToBeClickable" da classe "ExpectedConditions" (usado em waitClickable) usa o método "visibilityOfElementLocated" da classe "ExpectedConditions" (usado em waitVisibility) :

private void waitClickable(By by) {
WebDriverWait wait = new WebDriverWait(getDriver(), (BehaveConfig.getRunner_ScreenMaxWait() / 1000));
wait.until(ExpectedConditions.elementToBeClickable(by));
}

private void waitVisibility(By by) {
WebDriverWait wait = new WebDriverWait(getDriver(), (BehaveConfig.getRunner_ScreenMaxWait() / 1000));
wait.until(ExpectedConditions.visibilityOfElementLocated(by));
}

public static ExpectedCondition visibilityOfElementLocated(
final By locator) {
return new ExpectedCondition() {
@Override
public WebElement apply(WebDriver driver) {
try {
return elementIfVisible(findElement(locator, driver));
} catch (StaleElementReferenceException e) {
return null;
}
}

@Override
public String toString() {
return "visibility of element located by " + locator;
}
};
}

public static ExpectedCondition elementToBeClickable(
final By locator) {
return new ExpectedCondition() {

public ExpectedCondition visibilityOfElementLocated =
ExpectedConditions.visibilityOfElementLocated(locator);

@Override
public WebElement apply(WebDriver driver) {
WebElement element = visibilityOfElementLocated.apply(driver);
try {
if (element != null && element.isEnabled()) {
return element;
} else {
return null;
}
} catch (StaleElementReferenceException e) {
return null;
}
}

@Override
public String toString() {
return "element to be clickable: " + locator;
}
};
}