webdriver-snoy-0.6.0.4: a Haskell client for the Selenium WebDriver protocol

Safe HaskellNone
LanguageHaskell98

Test.WebDriver.Commands.Wait

Contents

Synopsis

Wait on expected conditions

waitUntil :: WDSessionState m => Double -> m a -> m a Source

Wait until either the given action succeeds or the timeout is reached. The action will be retried every .5 seconds until no ExpectFailed or FailedCommand NoSuchElement exceptions occur. If the timeout is reached, then a Timeout exception will be raised. The timeout value is expressed in seconds.

waitUntil' :: WDSessionState m => Int -> Double -> m a -> m a Source

Similar to waitUntil but allows you to also specify the poll frequency of the WD action. The frequency is expressed as an integer in microseconds.

waitWhile :: WDSessionState m => Double -> m a -> m () Source

Like waitUntil, but retries the action until it fails or until the timeout is exceeded.

waitWhile' :: WDSessionState m => Int -> Double -> m a -> m () Source

Like waitUntil', but retries the action until it either fails or until the timeout is exceeded.

Expected conditions

data ExpectFailed Source

An exception representing the failure of an expected condition.

expect :: MonadBaseControl IO m => Bool -> m () Source

An expected condition. This function allows you to express assertions in your explicit wait. This function raises ExpectFailed if the given boolean is False, and otherwise does nothing.

unexpected Source

Arguments

:: MonadBaseControl IO m 
=> String

Reason why the expected condition failed.

-> m a 

throws ExpectFailed. This is nice for writing your own abstractions.

Convenience functions

onTimeout :: MonadBaseControl IO m => m a -> m a -> m a Source

Convenience function to catch FailedCommand Timeout exceptions and perform some action.

Example:

waitUntil 5 (getText <=< findElem $ ByCSS ".class")
   `onTimeout` return ""

expectAny :: MonadBaseControl IO m => (a -> m Bool) -> [a] -> m () Source

Apply a monadic predicate to every element in a list, and expect that at least one succeeds.

expectAll :: MonadBaseControl IO m => (a -> m Bool) -> [a] -> m () Source

Apply a monadic predicate to every element in a list, and expect that all succeed.

ifM :: (ToBool bool, Monad m) => m bool -> m a -> m a -> m a

if' lifted to Monad. Unlike liftM3 if', this is short-circuiting in the monad, such that only the predicate action and one of the remaining argument actions are executed.

(<||>) :: (ToBool bool, Boolean bool, Monad m) => m bool -> m bool -> m bool infixr 2

Lifted inclusive disjunction. Unlike liftM2 (||), This function is short-circuiting in the monad. Fixity is the same as || (infixr 2).

(<&&>) :: (ToBool bool, Boolean bool, Monad m) => m bool -> m bool -> m bool infixr 3

Lifted conjunction. Unlike liftM2 (&&), this function is short-circuiting in the monad. Fixity is the same as && (infxr 3).

notM :: (Boolean bool, Monad m) => m bool -> m bool

Lifted boolean negation.