Search in sources :

Example 6 with Wait

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

the class Waiter method waitForUrlContains_IgnoreCase.

/**
 * Wait for a URL containing a specified String to open in the browser, ignoring the case of the url.
 * Checks whether a lower case value of the actual URL contains a lower case value of the expected String.
 * 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_IgnoreCase(String expectedString, WebDriver driver, int specifiedTimeout) {
    WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
    ExpectedCondition<Boolean> urlIsCorrect = arg0 -> driver.getCurrentUrl().toLowerCase().contains(expectedString.toLowerCase());
    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 7 with Wait

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

the class Waiter method waitForElementTextContainsString_IgnoreWhitespaces.

/**
 * Method that waits for the text on the element (whose
 * whitespaces are removed) to contain an expected String (whose whitespaces are also removed).
 * Basically, does a getText() on the WebElement, removes all whitespaces from this resulting String, then checks
 * that this value contains another String that has 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 contain 'str  ing 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 value expected to be part 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 waitForElementTextContainsString_IgnoreWhitespaces(WebElement element, String expectedString, WebDriver driver, int specifiedTimeout) {
    WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
    ExpectedCondition<Boolean> elementTextContainsString = arg0 -> element.getText().replaceAll("\\s", "").contains(expectedString.replaceAll("\\s", ""));
    wait.until(elementTextContainsString);
}
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 8 with Wait

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

the class Waiter method waitForElementAttributeContainsString_IgnoreWhitespaces.

/**
 * Method that waits for an element's attribute value (whose whitespaces are removed) to contain an expected
 * String (whose whitespaces are also removed).
 * Basically, does a getAttribute(nameOfAttribute) on the WebElement, removes all whitespaces from this resulting
 * String, then compares this value to another String that contains no whitespaces.
 * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
 * Whitespaces include: space, new line, tab.
 * Having said that, only the non whitespace characters are compared.
 * Will wait for up to the specified timeout number of seconds for expected condition to occur.
 *
 * @param element          - the WebElement whose attribute will be verified
 * @param attribute        - the attribute whose value will be verified
 * @param expectedString   - the expected value of the WebElement's attribute on which a whitespace removal is also
 *                         done
 * @param driver           - the WebDriver instance
 * @param specifiedTimeout - the amount of seconds to wait for the condition to occur
 */
public void waitForElementAttributeContainsString_IgnoreWhitespaces(WebElement element, String attribute, String expectedString, WebDriver driver, int specifiedTimeout) {
    WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
    ExpectedCondition<Boolean> elementAttributeContainsStringIW = arg0 -> element.getAttribute(attribute).replaceAll("\\s", "").contains(expectedString.replaceAll("\\s", ""));
    wait.until(elementAttributeContainsStringIW);
}
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 9 with Wait

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

the class Waiter method waitForUrl.

/**
 * Wait for a URL to open in the browser and for the page to load completely.
 * Wait for the specifiedTimeout number of seconds.
 *
 * @param url              - the URL to open
 * @param driver           - the WebDriver instance
 * @param specifiedTimeout - amount of seconds you want to wait for
 */
public void waitForUrl(String url, WebDriver driver, int specifiedTimeout) {
    WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
    ExpectedCondition<Boolean> urlIsCorrect = arg0 -> driver.getCurrentUrl().equals(url);
    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 10 with Wait

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

the class Waiter method waitForUrlStartsWith.

/**
 * Wait for the URL in the browser to start with a specified String.
 * Please see the startsWith method from the String class for details on how this method determines whether a
 * String starts with another one.
 * Wait for the specifiedTimeout number of seconds.
 *
 * @param expectedString   - the expected String to be found at the start of the URL loaded in the browser
 * @param driver           - the WebDriver instance
 * @param specifiedTimeout - amount of seconds you want to wait for
 */
public void waitForUrlStartsWith(String expectedString, WebDriver driver, int specifiedTimeout) {
    WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
    ExpectedCondition<Boolean> urlIsCorrect = arg0 -> driver.getCurrentUrl().startsWith(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)

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