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

Commit 0f243a8

Browse files
committed
Merge pull request #2 from jonsterling/ready/isEnabled
Add isEnabled binding
2 parents 4596b7d + 9ba1f6d commit 0f243a8

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

docs/Selenium.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Go to url
1414
wait :: forall e. Aff (selenium :: SELENIUM | e) Boolean -> Int -> Driver -> Aff (selenium :: SELENIUM | e) Unit
1515
```
1616

17-
Wait until first argument returns 'true'. If it returns false an error will be raised
17+
Wait until first argument returns 'true'. If it returns false an error will be raised
1818

1919
#### `quit`
2020

@@ -60,10 +60,10 @@ byXPath :: forall e. String -> Aff (selenium :: SELENIUM | e) Locator
6060
affLocator :: forall e. (Element -> Aff (selenium :: SELENIUM | e) Element) -> Aff (selenium :: SELENIUM | e) Locator
6161
```
6262

63-
Build locator from asynchronous function returning element.
63+
Build locator from asynchronous function returning element.
6464
I.e. this locator will find first visible element with `.common-element` class
65-
```purescript
66-
affLocator \el -> do
65+
```purescript
66+
affLocator \el -> do
6767
commonElements <- byCss ".common-element" >>= findElements el
6868
flagedElements <- traverse (\el -> Tuple el <$> isVisible el) commonElements
6969
maybe err pure $ foldl foldFn Nothing flagedElements
@@ -96,7 +96,7 @@ Finds elements by locator from `document`
9696
findChild :: forall e. Element -> Locator -> Aff (selenium :: SELENIUM | e) (Maybe Element)
9797
```
9898

99-
Same as `findElement` but starts searching from custom element
99+
Same as `findElement` but starts searching from custom element
100100

101101
#### `findChildren`
102102

@@ -174,6 +174,12 @@ getCssValue :: forall e. Element -> String -> Aff (selenium :: SELENIUM | e) Str
174174
isDisplayed :: forall e. Element -> Aff (selenium :: SELENIUM | e) Boolean
175175
```
176176

177+
#### `isEnabled`
178+
179+
``` purescript
180+
isEnabled :: forall e. Element -> Aff (selenium :: SELENIUM | e) Boolean
181+
```
182+
177183
#### `getInnerHtml`
178184

179185
``` purescript
@@ -186,9 +192,9 @@ getInnerHtml :: forall e. Element -> Aff (selenium :: SELENIUM | e) String
186192
clearEl :: forall e. Element -> Aff (selenium :: SELENIUM | e) Unit
187193
```
188194

189-
Clear `value` of element, if it has no value will do nothing.
190-
If `value` is weakly referenced by `virtual-dom` (`purescript-halogen`)
191-
will not work -- to clear such inputs one should use direct signal from
195+
Clear `value` of element, if it has no value will do nothing.
196+
If `value` is weakly referenced by `virtual-dom` (`purescript-halogen`)
197+
will not work -- to clear such inputs one should use direct signal from
192198
`Selenium.ActionSequence`
193199

194200

src/Selenium.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ exports.isDisplayed = function(el) {
156156
};
157157
};
158158

159+
exports.isEnabled = function(el) {
160+
return function(cb, eb) {
161+
return el.isEnabled().then(function(is) {
162+
return cb(is);
163+
}).thenCatch(eb);
164+
};
165+
};
166+
159167
exports.getCurrentUrl = function(driver) {
160168
return function(cb, eb) {
161169
return driver.getCurrentUrl().then(cb).thenCatch(eb);

src/Selenium.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module Selenium
2323
, getCssValue
2424
, getTitle
2525
, isDisplayed
26+
, isEnabled
2627
, getInnerHtml
2728
, clearEl
2829
) where
@@ -110,6 +111,7 @@ foreign import sendKeysEl :: forall e. String -> Element -> Aff (selenium :: SEL
110111
foreign import clickEl :: forall e. Element -> Aff (selenium :: SELENIUM|e) Unit
111112
foreign import getCssValue :: forall e. Element -> String -> Aff (selenium :: SELENIUM|e) String
112113
foreign import isDisplayed :: forall e. Element -> Aff (selenium :: SELENIUM|e) Boolean
114+
foreign import isEnabled :: forall e. Element -> Aff (selenium :: SELENIUM|e) Boolean
113115
foreign import getInnerHtml :: forall e. Element -> Aff (selenium :: SELENIUM|e) String
114116
-- | Clear `value` of element, if it has no value will do nothing.
115117
-- | If `value` is weakly referenced by `virtual-dom` (`purescript-halogen`)

0 commit comments

Comments
 (0)