@Component public final class Utils extends Object implements org.springframework.context.ApplicationContextAware
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_RETRY
default retry 5 times
|
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkMandatoryParam(String paramName,
Object object)
Checks that the provided parameter satisfies all mandatory preconditions.
|
static <T extends org.openqa.selenium.internal.WrapsElement> |
clear(T field)
Clear control and enter text
|
static <T extends org.openqa.selenium.WebElement> |
clear(T field)
Clear control
|
static <T extends org.openqa.selenium.internal.WrapsElement> |
clearAndType(T field,
String text)
Clear control and enter text
|
static <T extends org.openqa.selenium.WebElement> |
clearAndType(T field,
String text)
Clear control and enter text
|
static <T extends org.openqa.selenium.WebElement> |
clearAndTypeInvalidValues(T field,
String text)
Clear control and enter text without checking its value
|
static File |
createTempFile(String name)
Create temp file TODO ..
|
static boolean |
elementExists(org.openqa.selenium.By selector)
Helper method to see if element exists on page
|
static boolean |
elementExists(org.openqa.selenium.By selector,
long duration,
TimeUnit unit)
Helper method to see if element exists on page
|
static boolean |
elementExists(org.openqa.selenium.WebElement webElement,
org.openqa.selenium.By selector)
Helper method to see if element exists within element
|
static org.springframework.context.ApplicationContext |
getApplicationContext()
Helper to provide application context
|
static org.openqa.selenium.WebElement |
getVisibleElement(org.openqa.selenium.By selector)
Get the visible element from the list of elements that can be retrieved with the same selector
|
static org.openqa.selenium.WebDriver |
getWebDriver()
Helper to get web driver
|
static <T extends org.openqa.selenium.internal.WrapsElement> |
mouseOver(T wrapsElement)
Helper method to mouse over element
|
static <T extends org.openqa.selenium.WebElement> |
mouseOver(T webElement)
Helper to mouse over element
|
static <T> T |
retry(Retry<T> retry,
int count)
Helper method to retry the provided
code block, ignoring any Exceptions until either
the code block completes successfully or the maximum number of retries has been reached. |
static <T> T |
retry(Retry<T> retry,
int count,
Class<? extends Exception>... retryExceptions)
Helper method to retry the provided
code block, ignoring the specified exception types until either
the code block completes successfully or the maximum number of retries has been reached. |
static <T> T |
retryUntil(Retry<T> retry,
Supplier<Boolean> predicate,
int count)
Helper method to retry the provided
code block until the predicate block returns
true or the maximum number of retries has been reached. |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
static <T> void |
waitFor(org.openqa.selenium.support.ui.ExpectedCondition<T> condition) |
static org.openqa.selenium.WebElement |
waitForFind(org.openqa.selenium.By selector)
Waits for a web element to be found.
|
static org.openqa.selenium.WebElement |
waitForFind(org.openqa.selenium.WebElement webElement,
org.openqa.selenium.By selector)
Waits for a web element to be found in the scope of another element.
|
static void |
waitForInvisibilityOf(org.openqa.selenium.By locator)
Helper method to wait for the invisibility of an element located
by selector
|
static void |
waitForInvisibilityOf(org.openqa.selenium.WebElement webElement)
Helper method to wait for the invisibility of an element
|
static void |
waitForStalenessOf(ru.yandex.qatools.htmlelements.element.TypifiedElement webElement) |
static void |
waitForStalenessOf(org.openqa.selenium.WebElement webElement)
Helper method to wait for the staleness of an element
|
static org.openqa.selenium.WebElement |
waitForVisibilityOf(org.openqa.selenium.By locator)
Helper method to wait for the visibility of element located
by selector
|
static void |
waitForVisibilityOf(ru.yandex.qatools.htmlelements.element.TypifiedElement webElement) |
static void |
waitForVisibilityOf(org.openqa.selenium.WebElement webElement)
Helper method to wait for the visibility of an element
|
static org.openqa.selenium.support.ui.WebDriverWait |
webDriverWait()
Helper to get web driver wait object
|
static org.openqa.selenium.support.ui.WebDriverWait |
webDriverWait(long waitSeconds)
Helper to get web driver wait object
|
public static final int DEFAULT_RETRY
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)public static org.springframework.context.ApplicationContext getApplicationContext()
public static org.openqa.selenium.WebDriver getWebDriver()
public static org.openqa.selenium.support.ui.WebDriverWait webDriverWait(long waitSeconds)
public static org.openqa.selenium.support.ui.WebDriverWait webDriverWait()
public static boolean elementExists(org.openqa.selenium.By selector)
public static boolean elementExists(org.openqa.selenium.By selector,
long duration,
TimeUnit unit)
public static boolean elementExists(org.openqa.selenium.WebElement webElement,
org.openqa.selenium.By selector)
public static <T> void waitFor(org.openqa.selenium.support.ui.ExpectedCondition<T> condition)
public static org.openqa.selenium.WebElement waitForFind(org.openqa.selenium.By selector)
Throws TimeoutException if element is not found.
selector - selectorWebElement web elementpublic static org.openqa.selenium.WebElement waitForFind(org.openqa.selenium.WebElement webElement,
org.openqa.selenium.By selector)
Throws TimeoutException if element is not found.
webElement - web element to scope findselector - web selectorWebElement found web elementpublic static void waitForStalenessOf(org.openqa.selenium.WebElement webElement)
public static void waitForStalenessOf(ru.yandex.qatools.htmlelements.element.TypifiedElement webElement)
waitForStalenessOf(WebElement)public static void waitForVisibilityOf(org.openqa.selenium.WebElement webElement)
public static void waitForVisibilityOf(ru.yandex.qatools.htmlelements.element.TypifiedElement webElement)
waitForVisibilityOf(WebElement)public static org.openqa.selenium.WebElement waitForVisibilityOf(org.openqa.selenium.By locator)
public static void waitForInvisibilityOf(org.openqa.selenium.WebElement webElement)
public static void waitForInvisibilityOf(org.openqa.selenium.By locator)
public static <T extends org.openqa.selenium.WebElement> T mouseOver(T webElement)
webElement - public static <T extends org.openqa.selenium.internal.WrapsElement> T mouseOver(T wrapsElement)
wrapsElement - public static <T extends org.openqa.selenium.WebElement> T clear(T field)
public static <T extends org.openqa.selenium.WebElement> T clearAndType(T field,
String text)
public static <T extends org.openqa.selenium.WebElement> T clearAndTypeInvalidValues(T field,
String text)
public static <T extends org.openqa.selenium.internal.WrapsElement> T clear(T field)
public static <T extends org.openqa.selenium.internal.WrapsElement> T clearAndType(T field,
String text)
public static void checkMandatoryParam(String paramName, Object object)
paramName should be non-null and not blank.object should be non-null.objects should not be blank.objects should not be empty.paramName - parameter nameobject - object valueIllegalArgumentException - if any violations have occurred.public static File createTempFile(String name)
name - file nameFile filepublic static final <T> T retry(Retry<T> retry, int count)
code block, ignoring any Exceptions until either
the code block completes successfully or the maximum number of retries has been reached.T - the return type from the code block.retry - a code block to execute.count - maximum number of retries.public static final <T> T retry(Retry<T> retry, int count, Class<? extends Exception>... retryExceptions)
code block, ignoring the specified exception types until either
the code block completes successfully or the maximum number of retries has been reached.T - the return type from the code block.retry - a code block to execute.count - maximum number of retries.retryExceptions - a sequence of exception types any one of which will start a retry.public static final <T> T retryUntil(Retry<T> retry, Supplier<Boolean> predicate, int count)
code block until the predicate block returns
true or the maximum number of retries has been reached.
Note that any exceptions thrown within the Retry will not be caught internally and will be thrown
immediately.public static org.openqa.selenium.WebElement getVisibleElement(org.openqa.selenium.By selector)
selector - used to find elementsCopyright © 2005–2016 Alfresco Software. All rights reserved.