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

Commit a69d288

Browse files
committed
Merge pull request #26 from beckyconning/ready/tryToFind
Added tryToFind combinator
2 parents 8268f76 + e05c6ee commit a69d288

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

docs/Selenium/Combinators.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,23 @@ checkNotExistsByCss :: forall e o. String -> Selenium e o Unit
4646
contra :: forall e o a. Selenium e o a -> Selenium e o Unit
4747
```
4848

49-
#### `waiter`
49+
#### `tryToFind'`
5050

5151
``` purescript
52-
waiter :: forall e o a. Selenium e o a -> Int -> Selenium e o a
52+
tryToFind' :: forall e o. Int -> Selenium e o Locator -> Selenium e o Element
5353
```
5454

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

59-
#### `waitExistentCss`
58+
#### `tryToFind`
6059

6160
``` purescript
62-
waitExistentCss :: forall e o. String -> Int -> Selenium e o Element
61+
tryToFind :: forall e o. Selenium e o Locator -> Selenium e o Element
6362
```
6463

65-
#### `waitNotExistentCss`
66-
67-
``` purescript
68-
waitNotExistentCss :: forall e o. String -> Int -> Selenium e o Unit
69-
```
64+
Repeatedly tries to find an element using the provided selector until
65+
the provided `Selenium`'s `defaultTimeout` elapses.
7066

7167
#### `await`
7268

src/Selenium/Combinators.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ contra check = do
5959
(const $ pure unit)
6060
(const $ throwError $ error "check successed in contra") eR
6161

62+
-- | Repeatedly attempts to find an element using the provided selector until the
63+
-- | provided timeout elapses.
64+
tryToFind' :: forall e o. Int -> Selenium e o Locator -> Selenium e o Element
65+
tryToFind' timeout locator = tryRepeatedlyTo' timeout $ locator >>= findExact
66+
67+
-- | Repeatedly tries to find an element using the provided selector until
68+
-- | the provided `Selenium`'s `defaultTimeout` elapses.
69+
tryToFind :: forall e o. Selenium e o Locator -> Selenium e o Element
70+
tryToFind locator = tryRepeatedlyTo $ locator >>= findExact
71+
6272
-- | Repeatedly tries to evaluate check (third arg) for timeout ms (first arg)
6373
-- | finishes when check evaluates to true.
6474
-- | If there is an error during check or it constantly returns `false`

0 commit comments

Comments
 (0)