com.atlassian.webdriver.utils.element
Class WebDriverPoller

java.lang.Object
  extended by com.atlassian.webdriver.utils.element.WebDriverPoller

public final class WebDriverPoller
extends Object

A component that can be used to wait for certain conditions to happen on the tested page.

The conditions are expressed as a generic Function from WebDriver to boolean. ElementConditions contains factory methods to easily create some commonly used conditions.

The DEFAULT_TIMEOUT and DEFAULT_TIMEOUT_UNIT specify the default timeout used when no explicit timeout is provided by the client, which is currently 30 seconds. Clients are encouraged to use their own timeout specific to the situation.

NOTE: the default poll interval used by this class is as in the underlying WebDriverWait and is currently 500ms (subject to change as the underlying WebDriverWait implementation changes. This may be generally acceptable, but may not be granular enough for some scenarios (e.g. performance testing).

Example usage:

     {@code

Since:
2.2
See Also:
ElementConditions, WebDriverWait

Field Summary
static long DEFAULT_TIMEOUT
           
static TimeUnit DEFAULT_TIMEOUT_UNIT
           
 
Constructor Summary
WebDriverPoller(org.openqa.selenium.WebDriver webDriver)
           
WebDriverPoller(org.openqa.selenium.WebDriver webDriver, long timeout, TimeUnit timeUnit)
           
 
Method Summary
 void waitUntil(com.google.common.base.Function<org.openqa.selenium.WebDriver,Boolean> condition)
          Wait until condition is true up to the default timeout.
 void waitUntil(com.google.common.base.Function<org.openqa.selenium.WebDriver,Boolean> condition, long timeoutInSeconds)
          Wait until condition up to the timeoutInSeconds.
 void waitUntil(com.google.common.base.Function<org.openqa.selenium.WebDriver,Boolean> condition, long timeout, TimeUnit unit)
          Wait until condition up to the timeout specified by unit.
 WebDriverPoller withDefaultTimeout(long timeout, TimeUnit timeUnit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final long DEFAULT_TIMEOUT
See Also:
Constant Field Values

DEFAULT_TIMEOUT_UNIT

public static final TimeUnit DEFAULT_TIMEOUT_UNIT
Constructor Detail

WebDriverPoller

@Inject
public WebDriverPoller(@Nonnull
                              org.openqa.selenium.WebDriver webDriver)

WebDriverPoller

public WebDriverPoller(@Nonnull
                       org.openqa.selenium.WebDriver webDriver,
                       long timeout,
                       @Nonnull
                       TimeUnit timeUnit)
Method Detail

withDefaultTimeout

public WebDriverPoller withDefaultTimeout(long timeout,
                                          TimeUnit timeUnit)

waitUntil

public void waitUntil(com.google.common.base.Function<org.openqa.selenium.WebDriver,Boolean> condition)
Wait until condition is true up to the default timeout. The default timeout depends on the arguments supplied while creating an instance of this WebDriverPoller.

Parameters:
condition - condition that must evaluate to true
Throws:
org.openqa.selenium.TimeoutException - if the condition does not come true before the timeout expires
See Also:
DEFAULT_TIMEOUT, DEFAULT_TIMEOUT_UNIT

waitUntil

public void waitUntil(com.google.common.base.Function<org.openqa.selenium.WebDriver,Boolean> condition,
                      long timeoutInSeconds)
Wait until condition up to the timeoutInSeconds.

Parameters:
condition - condition that must evaluate to true
timeoutInSeconds - timeout in seconds to wait for condition to come true
Throws:
org.openqa.selenium.TimeoutException - if the condition does not come true before the timeout expires

waitUntil

public void waitUntil(com.google.common.base.Function<org.openqa.selenium.WebDriver,Boolean> condition,
                      long timeout,
                      TimeUnit unit)
Wait until condition up to the timeout specified by unit.

Parameters:
condition - condition that must evaluate to true
timeout - timeout to wait for condition to come true
unit - unit of the timeout
Throws:
org.openqa.selenium.TimeoutException - if the condition does not come true before the timeout expires


Copyright © 2014 Atlassian. All rights reserved.