Search in sources :

Example 21 with Wait

use of org.openqa.selenium.support.ui.Wait 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);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) Wait(org.openqa.selenium.support.ui.Wait) WebDriver(org.openqa.selenium.WebDriver) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 22 with Wait

use of org.openqa.selenium.support.ui.Wait 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);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) Wait(org.openqa.selenium.support.ui.Wait) WebDriver(org.openqa.selenium.WebDriver) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 23 with Wait

use of org.openqa.selenium.support.ui.Wait 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);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) Wait(org.openqa.selenium.support.ui.Wait) WebDriver(org.openqa.selenium.WebDriver) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 24 with Wait

use of org.openqa.selenium.support.ui.Wait in project thewaiter by iamalittletester.

the class Waiter method waitForElementTextEqualsString_IgnoreWhitespaces.

/**
 * Method that waits for the text on the element (whose
 * whitespaces are removed) to equal an expected String (whose whitespaces are also removed).
 * Basically, does a getText() on the WebElement, removes all whitespaces from this resulting String, then compares
 * this value to another String that contains no whitespaces.
 * Whitespaces include: space, new line, tab.
 * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
 * Therefore, 'this      string  here' will equal 'this string here'.
 * 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 after removing the
 *                         whitespaces on this text
 * @param expectedString   - the expected value of the WebElement's text on which a whitespace removal is also done
 * @param driver           - the WebDriver instance
 * @param specifiedTimeout - amount of seconds you want to wait for
 */
public void waitForElementTextEqualsString_IgnoreWhitespaces(WebElement element, String expectedString, WebDriver driver, int specifiedTimeout) {
    WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
    ExpectedCondition<Boolean> elementTextEqualsString = arg0 -> element.getText().replaceAll("\\s", "").equals(expectedString.replaceAll("\\s", ""));
    wait.until(elementTextEqualsString);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) Wait(org.openqa.selenium.support.ui.Wait) WebDriver(org.openqa.selenium.WebDriver) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 25 with Wait

use of org.openqa.selenium.support.ui.Wait in project thewaiter by iamalittletester.

the class Waiter method waitForElementTextEqualsString_IgnoreCase.

/**
 * Method that waits for the text on the element to equal an
 * expected String but ignoring the case of the two.
 * Compares the value resulted from getText() on the element with the expected String, but without taking into
 * account the case of the two values.
 * Therefore, for example 'tHis' and 'This' will be equal when calling this method.
 * 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_IgnoreCase(WebElement element, String expectedString, WebDriver driver, int specifiedTimeout) {
    WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
    ExpectedCondition<Boolean> elementTextEqualsStringIgnoreCase = arg0 -> element.getText().equalsIgnoreCase(expectedString);
    wait.until(elementTextEqualsStringIgnoreCase);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) Wait(org.openqa.selenium.support.ui.Wait) WebDriver(org.openqa.selenium.WebDriver) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Aggregations

Wait (org.openqa.selenium.support.ui.Wait)29 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)27 WebDriver (org.openqa.selenium.WebDriver)23 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)22 WebElement (org.openqa.selenium.WebElement)22 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)22 Function (java.util.function.Function)9 TimeoutException (org.openqa.selenium.TimeoutException)7 SpecialKeywords (com.qaprosoft.carina.core.foundation.commons.SpecialKeywords)6 CryptoTool (com.qaprosoft.carina.core.foundation.crypto.CryptoTool)6 Configuration (com.qaprosoft.carina.core.foundation.utils.Configuration)6 Parameter (com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter)6 LogicUtils (com.qaprosoft.carina.core.foundation.utils.LogicUtils)6 Messager (com.qaprosoft.carina.core.foundation.utils.Messager)6 CommonUtils (com.qaprosoft.carina.core.foundation.utils.common.CommonUtils)6 ExtendedWebElement (com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement)6 AbstractPage (com.qaprosoft.carina.core.gui.AbstractPage)6 List (java.util.List)6 Matcher (java.util.regex.Matcher)6 Pattern (java.util.regex.Pattern)6