<T>
wait(condition, opt_timeout, opt_message)code »
Schedules a task that shall wait for a condition to hold. Each condition
function may return any value, but it will always be evaluated as a boolean.
Condition functions may schedule sub-tasks with this instance, however,
their execution time will be factored into whether a wait has timed out.
In the event a condition returns a Promise, the polling loop will wait for
it to be resolved before evaluating whether the condition has been satisfied.
The resolution time for a promise is factored into whether a wait has timed
out.
If the condition function throws, or returns a rejected promise, the
wait task will fail.
If the condition is defined as a promise, the flow will wait for it to
settle. If the timeout expires before the promise settles, the promise
returned by this function will be rejected.
If this function is invoked with timeout === 0
, or the timeout is omitted,
the flow will wait indefinitely for the condition to be satisfied.
Parameters
- condition
(webdriver.promise.Promise<T>|function(): ?)
The condition to poll,
or a promise to wait on.
- opt_timeout
number=
How long to wait, in milliseconds, for the
condition to hold before timing out. If omitted, the flow will wait
indefinitely.
- opt_message
string=
An optional error message to include if the
wait times out; defaults to the empty string.
Returns
webdriver.promise.Promise<T>
A promise that will be fulfilled
when the condition has been satisified. The promise shall be rejected if
the wait times out waiting for the condition.
Throws
TypeError
If condition is not a function or promise or if timeout
is not a number >= 0.