public class DefaultConditionRunner extends Object implements ConditionRunner
RuntimeException
when the
condition is not met in the waitFor(Condition)
method. More specific
runners are preferred for different testing frameworks. E.g. JUnit tests
would prefer to use JUnitConditionRunner
.Modifier and Type | Class and Description |
---|---|
static class |
DefaultConditionRunner.Log4jMonitor
A Log4j implementation of
DefaultConditionRunner.Monitor . |
static interface |
DefaultConditionRunner.Monitor
A
DefaultConditionRunner.Monitor can be installed in DefaultConditionRunner as an open ended way of
being notified of certain events. |
static class |
DefaultConditionRunner.NoOpMonitor
A no-op implementation of
DefaultConditionRunner.Monitor . |
ConditionRunner.Context
Constructor and Description |
---|
DefaultConditionRunner(DefaultConditionRunner.Monitor monitor,
com.thoughtworks.selenium.Selenium selenium,
int interval,
int timeout) |
DefaultConditionRunner(DefaultConditionRunner.Monitor monitor,
com.thoughtworks.selenium.Selenium selenium,
int initialDelay,
int interval,
int timeout) |
DefaultConditionRunner(com.thoughtworks.selenium.Selenium selenium)
Constructs an instance of this class with reasonable defaults.
|
DefaultConditionRunner(com.thoughtworks.selenium.Selenium selenium,
int interval,
int timeout)
Constructs an instance of this class with a
DefaultConditionRunner.NoOpMonitor . |
DefaultConditionRunner(com.thoughtworks.selenium.Selenium selenium,
int initialDelay,
int interval,
int timeout)
Constructs an instance of this class with a
DefaultConditionRunner.NoOpMonitor . |
Modifier and Type | Method and Description |
---|---|
protected void |
throwAssertionException(String message) |
protected void |
throwAssertionException(String message,
Throwable throwable) |
void |
waitFor(Condition condition)
This method will, every so often, evaluate the given
condition 's
Condition.isTrue(ConditionRunner.Context) method, until:
it becomes true, in which case it simply returns
a certain amount of time is passed, in which case it fails by throwing an failure exception
tailored to a given test framework -- e.g. |
void |
waitFor(String narrative,
Condition condition)
As above but with an additional 'should' phrase narrative used in the event of the condition
failing to become true
|
public DefaultConditionRunner(DefaultConditionRunner.Monitor monitor, com.thoughtworks.selenium.Selenium selenium, int initialDelay, int interval, int timeout)
monitor
- the Monitorselenium
- the selenium to be passed to the Conditions run from within this runner.initialDelay
- (in millis) how long to wait before the initial test of the conditioninterval
- (in millis) when waiting for a condition, how long to wait between calls to
Condition.isTrue(com.thoughtworks.selenium.condition.ConditionRunner.Context)
timeout
- (in millis) when waiting for a condition, how long to wait until we give up.public DefaultConditionRunner(DefaultConditionRunner.Monitor monitor, com.thoughtworks.selenium.Selenium selenium, int interval, int timeout)
monitor
- the Monitorselenium
- the selenium to be passed to the Conditions run from within this runner.interval
- (in millis) when waiting for a condition, how long to wait between calls to
Condition.isTrue(com.thoughtworks.selenium.condition.ConditionRunner.Context)
timeout
- (in millis) when waiting for a condition, how long to wait until we give up.public DefaultConditionRunner(com.thoughtworks.selenium.Selenium selenium, int initialDelay, int interval, int timeout)
DefaultConditionRunner.NoOpMonitor
.selenium
- the selenium to be passed to the Conditions run from within this runner.initialDelay
- (in millis) how long to wait before the initial test of the conditioninterval
- (in millis) when waiting for a condition, how long to wait between calls to
Condition.isTrue(com.thoughtworks.selenium.condition.ConditionRunner.Context)
timeout
- (in millis) when waiting for a condition, how long to wait until we give up.DefaultConditionRunner(Monitor, Selenium, int, int)
public DefaultConditionRunner(com.thoughtworks.selenium.Selenium selenium, int interval, int timeout)
DefaultConditionRunner.NoOpMonitor
.selenium
- the selenium to be passed to the Conditions run from within this runner.interval
- (in millis) when waiting for a condition, how long to wait between calls to
Condition.isTrue(com.thoughtworks.selenium.condition.ConditionRunner.Context)
timeout
- (in millis) when waiting for a condition, how long to wait until we give up.DefaultConditionRunner(Monitor, Selenium, int, int)
public DefaultConditionRunner(com.thoughtworks.selenium.Selenium selenium)
selenium
- the selenium to be passed to the Conditions run from within this runner.DefaultConditionRunner(Monitor, Selenium, int, int)
public void waitFor(Condition condition)
ConditionRunner
condition
's
Condition.isTrue(ConditionRunner.Context)
method, until:
AssertionFailedError
in the
case of JUnit
RuntimeException
and
rethrown
How often if "every so often" and how long is the "certain amount of time" is left to the specific implementations of this interface.
waitFor
in interface ConditionRunner
condition
- conditionpublic void waitFor(String narrative, Condition condition)
ConditionRunner
waitFor
in interface ConditionRunner
narrative
- narrativecondition
- conditionprotected void throwAssertionException(String message)
Copyright © 2016. All rights reserved.