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

Add getAttribute binding #3

Merged
merged 1 commit into from
Aug 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
22 changes: 14 additions & 8 deletions docs/Selenium.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Go to url
wait :: forall e. Aff (selenium :: SELENIUM | e) Boolean -> Int -> Driver -> Aff (selenium :: SELENIUM | e) Unit
```

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

#### `quit`

Expand Down Expand Up @@ -60,10 +60,10 @@ byXPath :: forall e. String -> Aff (selenium :: SELENIUM | e) Locator
affLocator :: forall e. (Element -> Aff (selenium :: SELENIUM | e) Element) -> Aff (selenium :: SELENIUM | e) Locator
```

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

Same as `findElement` but starts searching from custom element
Same as `findElement` but starts searching from custom element

#### `findChildren`

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

#### `getAttribute`

``` purescript
getAttribute :: forall e. Element -> String -> Aff (selenium :: SELENIUM | e) String
```

#### `isDisplayed`

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

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


8 changes: 8 additions & 0 deletions src/Selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ exports.getCssValue = function(el) {
};
};

exports.getAttribute = function(el) {
return function(str) {
return function(cb, eb) {
return el.getAttribute(str).then(cb).thenCatch(eb);
};
};
};

exports.isDisplayed = function(el) {
return function(cb, eb) {
return el.isDisplayed().then(function(is) {
Expand Down
2 changes: 2 additions & 0 deletions src/Selenium.purs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Selenium
, sendKeysEl
, clickEl
, getCssValue
, getAttribute
, getTitle
, isDisplayed
, isEnabled
Expand Down Expand Up @@ -110,6 +111,7 @@ foreign import executeStr :: forall e. Driver -> String -> Aff (selenium :: SELE
foreign import sendKeysEl :: forall e. String -> Element -> Aff (selenium :: SELENIUM|e) Unit
foreign import clickEl :: forall e. Element -> Aff (selenium :: SELENIUM|e) Unit
foreign import getCssValue :: forall e. Element -> String -> Aff (selenium :: SELENIUM|e) String
foreign import getAttribute :: forall e. Element -> String -> Aff (selenium :: SELENIUM|e) String
foreign import isDisplayed :: forall e. Element -> Aff (selenium :: SELENIUM|e) Boolean
foreign import isEnabled :: forall e. Element -> Aff (selenium :: SELENIUM|e) Boolean
foreign import getInnerHtml :: forall e. Element -> Aff (selenium :: SELENIUM|e) String
Expand Down