public class WaitFor
extends java.lang.Object
Browser.waitFor()
.
Sometimes it is necessary to wait for the web page, which needs to complete loading page elements. This is usually the case when JavaScript gets executed, mostly AJAX calls. Wait conditions can be customized by specifying own JavaScript code.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TIMEOUT_ON_WAIT |
Constructor and Description |
---|
WaitFor(Browser browser)
Constructs new BrowserWait instance to be able to define wait conditions.
|
WaitFor(Browser browser,
int timeout)
Constructs new BrowserWait instance to be able to define wait conditions.
|
Modifier and Type | Method and Description |
---|---|
void |
element(java.lang.String query)
Waits until element is found.
|
void |
elementText(HtmlElement element,
java.lang.String text)
Waits until element contains the specified text.
|
void |
elementText(java.lang.String query,
java.lang.String text)
Waits until element contains the specified text.
|
void |
evaluatedJavaScriptExpression(java.lang.String expression)
Waits until the specified JavaScript returns a non-false value.
|
void |
evaluatedJavaScriptExpression(java.lang.String expression,
int timeout)
Waits until the specified JavaScript returns a non-false value.
|
void |
query(Query query)
Waits until element is found.
|
public static final int DEFAULT_TIMEOUT_ON_WAIT
public WaitFor(Browser browser)
The default timeout length is 20 seconds.
browser
- Browser
instance to work withpublic WaitFor(Browser browser, int timeout)
browser
- Browser
instance to work withtimeout
- wait for this amount of seconds until a timeout exception is thrownpublic void query(Query query) throws java.util.concurrent.TimeoutException
query
- the element queryjava.util.concurrent.TimeoutException
public void element(java.lang.String query) throws java.util.concurrent.TimeoutException
query
- the element which needs to be found, identified by the visible text or attribute valuesjava.util.concurrent.TimeoutException
public void elementText(HtmlElement element, java.lang.String text) throws java.util.concurrent.TimeoutException
element
- the element to observetext
- when the element contains this text the execution of the program will be continuedjava.util.concurrent.TimeoutException
public void elementText(java.lang.String query, java.lang.String text) throws java.util.concurrent.TimeoutException
query
- the found element should contain the text or attribute value specified heretext
- when the element contains this text the execution of the program will be continuedjava.util.concurrent.TimeoutException
public void evaluatedJavaScriptExpression(java.lang.String expression, int timeout) throws java.util.concurrent.TimeoutException
expression
- the JavaScript expression to evaluatetimeout
- time in seconds to wait until a TimeoutException is thrownjava.util.concurrent.TimeoutException
public void evaluatedJavaScriptExpression(java.lang.String expression) throws java.util.concurrent.TimeoutException
expression
- the JavaScript expression to evaluatejava.util.concurrent.TimeoutException