use of org.openqa.selenium.support.ui.ExpectedCondition in project mamute by caelum.
the class AcceptanceTestBase method waitForFirstBodyPresence.
private static void waitForFirstBodyPresence() {
driver.get(SERVER.urlFor(""));
ExpectedCondition<WebElement> homeAppear = new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver d) {
return d.findElement(By.tagName("body"));
}
};
new WebDriverWait(driver, 40).until(homeAppear);
}
use of org.openqa.selenium.support.ui.ExpectedCondition in project NoraUi by NoraUi.
the class Utilities method visibilityOfNbElementsLocatedBy.
/**
* An expectation for checking that nb elements present on the web page that match the locator
* are visible. Visibility means that the elements are not only displayed but also have a height
* and width that is greater than 0.
*
* @param locator
* used to find the element
* @param nb
* is exactly number of responses
* @return the list of WebElements once they are located
*/
public static ExpectedCondition<List<WebElement>> visibilityOfNbElementsLocatedBy(final By locator, final int nb) {
return new ExpectedCondition<List<WebElement>>() {
@Override
public List<WebElement> apply(WebDriver driver) {
int nbElementIsDisplayed = 0;
final List<WebElement> elements = driver.findElements(locator);
for (final WebElement element : elements) {
if (element.isDisplayed()) {
nbElementIsDisplayed++;
}
}
return nbElementIsDisplayed == nb ? elements : null;
}
};
}
use of org.openqa.selenium.support.ui.ExpectedCondition in project thewaiter by iamalittletester.
the class Waiter method waitForElementTextEqualsString.
/**
* Method that waits for the text on the element to equal an expected String.
* Compares the value resulted from getText() on the element with the expected String.
* Will wait for up to the specifiedTimeout number of seconds for the text on the element to be the expected one.
*
* @param element - the WebElement whose text will be compared to an expected value
* @param expectedString - the expected value of the WebElement's text
* @param driver - the WebDriver instance
* @param specifiedTimeout - amount of seconds you want to wait for
*/
public void waitForElementTextEqualsString(WebElement element, String expectedString, WebDriver driver, int specifiedTimeout) {
WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
ExpectedCondition<Boolean> elementTextEqualsString = arg0 -> element.getText().equals(expectedString);
wait.until(elementTextEqualsString);
}
use of org.openqa.selenium.support.ui.ExpectedCondition in project thewaiter by iamalittletester.
the class Waiter method waitForUrlContains.
/**
* Wait for a URL containing a specified String to open in the browser.
* The URL will not equal the specified String. Just contain it.
* Wait for the specifiedTimeout number of seconds.
*
* @param expectedString - the String that needs to be included in the URL
* @param driver - the WebDriver instance
* @param specifiedTimeout - amount of seconds you want to wait for
*/
public void waitForUrlContains(String expectedString, WebDriver driver, int specifiedTimeout) {
WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
ExpectedCondition<Boolean> urlIsCorrect = arg0 -> driver.getCurrentUrl().contains(expectedString);
wait.until(urlIsCorrect);
waitForPageLoadComplete(driver, specifiedTimeout);
}
use of org.openqa.selenium.support.ui.ExpectedCondition in project thewaiter by iamalittletester.
the class Waiter method waitForElementAttributeEqualsString_IgnoreCase.
/**
* Method that waits for an element's specified attribute's value to equal another specified String, no matter
* the case of the actual or expected value.
* Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String,
* ignoring the cases.
* Will wait for up to the TIMEOUT number of seconds for an element's attribute value to equal an expected String.
*
* @param element - the WebElement whose attribute we are interested in
* @param attribute - the attribute whose value needs to be compared to another value
* @param expectedString - the expected value of the WebElement's attribute, case insensitive
* @param driver - the WebDriver instance
* @param specifiedTimeout - amount of seconds you want to wait for
*/
public void waitForElementAttributeEqualsString_IgnoreCase(WebElement element, String attribute, String expectedString, WebDriver driver, int specifiedTimeout) {
WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
ExpectedCondition<Boolean> elementAttributeEqualsStringIgnoreCase = arg0 -> element.getAttribute(attribute).equalsIgnoreCase(expectedString);
wait.until(elementAttributeEqualsStringIgnoreCase);
}
Aggregations