Skip to content
This repository was archived by the owner on Jan 17, 2020. It is now read-only.

Added tryToFind combinator #26

Merged
merged 1 commit into from
Sep 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions docs/Selenium/Combinators.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,23 @@ checkNotExistsByCss :: forall e o. String -> Selenium e o Unit
contra :: forall e o a. Selenium e o a -> Selenium e o Unit
```

#### `waiter`
#### `tryToFind'`

``` purescript
waiter :: forall e o a. Selenium e o a -> Int -> Selenium e o a
tryToFind' :: forall e o. Int -> Selenium e o Locator -> Selenium e o Element
```

takes value and repeatedly tries to evaluate it for timeout of ms (second arg)
if it evaluates w/o error returns its value
else throws error
Repeatedly attempts to find an element using the provided selector until the
provided timeout elapses.

#### `waitExistentCss`
#### `tryToFind`

``` purescript
waitExistentCss :: forall e o. String -> Int -> Selenium e o Element
tryToFind :: forall e o. Selenium e o Locator -> Selenium e o Element
```

#### `waitNotExistentCss`

``` purescript
waitNotExistentCss :: forall e o. String -> Int -> Selenium e o Unit
```
Repeatedly tries to find an element using the provided selector until
the provided `Selenium`'s `defaultTimeout` elapses.

#### `await`

Expand Down
10 changes: 10 additions & 0 deletions src/Selenium/Combinators.purs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ contra check = do
(const $ pure unit)
(const $ throwError $ error "check successed in contra") eR

-- | Repeatedly attempts to find an element using the provided selector until the
-- | provided timeout elapses.
tryToFind' :: forall e o. Int -> Selenium e o Locator -> Selenium e o Element
tryToFind' timeout locator = tryRepeatedlyTo' timeout $ locator >>= findExact

-- | Repeatedly tries to find an element using the provided selector until
-- | the provided `Selenium`'s `defaultTimeout` elapses.
tryToFind :: forall e o. Selenium e o Locator -> Selenium e o Element
tryToFind locator = tryRepeatedlyTo $ locator >>= findExact

-- | Repeatedly tries to evaluate check (third arg) for timeout ms (first arg)
-- | finishes when check evaluates to true.
-- | If there is an error during check or it constantly returns `false`
Expand Down