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

Commit 0205065

Browse files
committed
Merge pull request #3 from jonsterling/ready/get-attribute
Add getAttribute binding
2 parents 0f243a8 + b9158a6 commit 0205065

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

@@ -168,6 +168,12 @@ clickEl :: forall e. Element -> Aff (selenium :: SELENIUM | e) Unit
168168
getCssValue :: forall e. Element -> String -> Aff (selenium :: SELENIUM | e) String
169169
```
170170

171+
#### `getAttribute`
172+
173+
``` purescript
174+
getAttribute :: forall e. Element -> String -> Aff (selenium :: SELENIUM | e) String
175+
```
176+
171177
#### `isDisplayed`
172178

173179
``` purescript
@@ -192,9 +198,9 @@ getInnerHtml :: forall e. Element -> Aff (selenium :: SELENIUM | e) String
192198
clearEl :: forall e. Element -> Aff (selenium :: SELENIUM | e) Unit
193199
```
194200

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
201+
Clear `value` of element, if it has no value will do nothing.
202+
If `value` is weakly referenced by `virtual-dom` (`purescript-halogen`)
203+
will not work -- to clear such inputs one should use direct signal from
198204
`Selenium.ActionSequence`
199205

200206

src/Selenium.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ exports.getCssValue = function(el) {
148148
};
149149
};
150150

151+
exports.getAttribute = function(el) {
152+
return function(str) {
153+
return function(cb, eb) {
154+
return el.getAttribute(str).then(cb).thenCatch(eb);
155+
};
156+
};
157+
};
158+
151159
exports.isDisplayed = function(el) {
152160
return function(cb, eb) {
153161
return el.isDisplayed().then(function(is) {

src/Selenium.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Selenium
2121
, sendKeysEl
2222
, clickEl
2323
, getCssValue
24+
, getAttribute
2425
, getTitle
2526
, isDisplayed
2627
, isEnabled
@@ -110,6 +111,7 @@ foreign import executeStr :: forall e. Driver -> String -> Aff (selenium :: SELE
110111
foreign import sendKeysEl :: forall e. String -> Element -> Aff (selenium :: SELENIUM|e) Unit
111112
foreign import clickEl :: forall e. Element -> Aff (selenium :: SELENIUM|e) Unit
112113
foreign import getCssValue :: forall e. Element -> String -> Aff (selenium :: SELENIUM|e) String
114+
foreign import getAttribute :: forall e. Element -> String -> Aff (selenium :: SELENIUM|e) String
113115
foreign import isDisplayed :: forall e. Element -> Aff (selenium :: SELENIUM|e) Boolean
114116
foreign import isEnabled :: forall e. Element -> Aff (selenium :: SELENIUM|e) Boolean
115117
foreign import getInnerHtml :: forall e. Element -> Aff (selenium :: SELENIUM|e) String

0 commit comments

Comments
 (0)