use of org.openqa.selenium.support.ui.Wait in project carina by qaprosoft.
the class DriverHelper method findExtendedWebElement.
/**
* Find Extended Web Element on page using By.
*
* @param by
* Selenium By locator
* @param name
* Element name
* @param timeout
* Timeout to find
* @return ExtendedWebElement if exists otherwise null.
*/
public ExtendedWebElement findExtendedWebElement(final By by, String name, long timeout) {
ExtendedWebElement element;
final WebDriver drv = getDriver();
wait = new WebDriverWait(drv, timeout, RETRY_TIME);
try {
setImplicitTimeout(0);
wait.until((Function<WebDriver, Object>) dr -> !drv.findElements(by).isEmpty());
element = new ExtendedWebElement(driver.findElement(by), name, by, driver);
Messager.ELEMENT_FOUND.info(name);
} catch (Exception e) {
element = null;
Messager.ELEMENT_NOT_FOUND.error(name);
throw new RuntimeException(e);
} finally {
setImplicitTimeout(IMPLICIT_TIMEOUT);
}
return element;
}
use of org.openqa.selenium.support.ui.Wait in project thewaiter by iamalittletester.
the class Waiter method waitForElementTextContainsString.
/**
* Method that waits for the text on the element to contain an expected String.
* Checks whether the value resulted from getText() on the element contains the expected String.
* Will wait for up to the specifiedTimeout number of seconds for the text on the element to contain the expected one.
*
* @param element - the WebElement whose text will be checked
* @param expectedString - the value expected to be contained in the WebElement's text
* @param driver - the WebDriver instance
* @param specifiedTimeout - amount of seconds you want to wait for
*/
public void waitForElementTextContainsString(WebElement element, String expectedString, WebDriver driver, int specifiedTimeout) {
WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
ExpectedCondition<Boolean> elementTextContainsString = arg0 -> element.getText().contains(expectedString);
wait.until(elementTextContainsString);
}
use of org.openqa.selenium.support.ui.Wait in project thewaiter by iamalittletester.
the class Waiter method waitForElementAttributeEqualsString.
/**
* Method that waits for an element's specified attribute's value to equal another specified String.
* Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String.
* Will wait for up to the specified 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
* @param driver - the WebDriver instance
* @param specifiedTimeout - amount of seconds you want to wait for
*/
public void waitForElementAttributeEqualsString(WebElement element, String attribute, String expectedString, WebDriver driver, int specifiedTimeout) {
WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
ExpectedCondition<Boolean> elementAttributeEqualsString = arg0 -> element.getAttribute(attribute).equals(expectedString);
wait.until(elementAttributeEqualsString);
}
use of org.openqa.selenium.support.ui.Wait in project thewaiter by iamalittletester.
the class Waiter method click.
/**
* Try to click on an element during the specifiedTimeout number of seconds.
*
* @param element - the element to click on
* @param driver - the WebDriver instance
* @param specifiedTimeout - amount of seconds you want to wait for
*/
public void click(WebElement element, WebDriver driver, int specifiedTimeout) {
WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
ExpectedCondition<Boolean> elementIsClickable = arg0 -> {
try {
element.click();
return true;
} catch (Exception e) {
return false;
}
};
wait.until(elementIsClickable);
}
use of org.openqa.selenium.support.ui.Wait in project thewaiter by iamalittletester.
the class Waiter method waitForElementAttributeContainsString_IgnoreCase.
/**
* Method that waits for an element's specified attribute's value to contain 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 specifiedTimeout number of seconds for the expected condition to occur.
*
* @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 waitForElementAttributeContainsString_IgnoreCase(WebElement element, String attribute, String expectedString, WebDriver driver, int specifiedTimeout) {
WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
ExpectedCondition<Boolean> elementAttributeContainsStringIC = arg0 -> element.getAttribute(attribute).toLowerCase().contains(expectedString.toLowerCase());
wait.until(elementAttributeContainsStringIC);
}
Aggregations