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

Commit 457e346

Browse files
committed
Merge pull request #7 from jonsterling/ready/capabilities
Add preliminary support for setting custom capabilities
2 parents 9987737 + 05c9ade commit 457e346

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

docs/Selenium.md

Lines changed: 8 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

@@ -198,9 +198,9 @@ getInnerHtml :: forall e. Element -> Aff (selenium :: SELENIUM | e) String
198198
clearEl :: forall e. Element -> Aff (selenium :: SELENIUM | e) Unit
199199
```
200200

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
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
204204
`Selenium.ActionSequence`
205205

206206

docs/Selenium/Builder.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ usingServer :: String -> Build Unit
3939
scrollBehaviour :: ScrollBehaviour -> Build Unit
4040
```
4141

42+
#### `withCapabilities`
43+
44+
``` purescript
45+
withCapabilities :: Capabilities -> Build Unit
46+
```
47+
4248
#### `build`
4349

4450
``` purescript

src/Selenium/Builder.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ exports._usingServer = function(b, s) {
3737
exports._setScrollBehaviour = function(b, bh) {
3838
return b.setScrollBehaviour(bh);
3939
};
40+
41+
exports._withCapabilities = function(b, c) {
42+
return b.withCapabilities(c);
43+
};

src/Selenium/Builder.purs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Selenium.Builder
44
, forBrowser
55
, usingServer
66
, scrollBehaviour
7+
, withCapabilities
78
, Build()
89
) where
910

@@ -68,10 +69,13 @@ usingServer = rule <<< UsingServer
6869
scrollBehaviour :: ScrollBehaviour -> Build Unit
6970
scrollBehaviour = rule <<< SetScrollBehaviour
7071

71-
build :: forall e. Build Unit -> Aff (selenium :: SELENIUM|e) Driver
72-
build commands = do
72+
withCapabilities :: Capabilities -> Build Unit
73+
withCapabilities = rule <<< WithCapabilities
74+
75+
build :: forall e. Build Unit -> Aff (selenium :: SELENIUM|e) Driver
76+
build commands = do
7377
builder <- _newBuilder
74-
_build $ interpret (execWriter $ unBuild commands) builder
78+
_build $ interpret (execWriter $ unBuild commands) builder
7579

7680

7781
interpret :: List Command -> Builder -> Builder
@@ -82,13 +86,15 @@ interpret commands b = foldl foldFn b commands
8286
foldFn b (ForBrowser br v p) = runFn4 _forBrowser b br v p
8387
foldFn b (UsingServer s) = runFn2 _usingServer b s
8488
foldFn b (SetScrollBehaviour bh) = runFn2 _setScrollBehaviour b bh
89+
foldFn b (WithCapabilities c) = runFn2 _withCapabilities b c
8590
foldFn b _ = b
8691

8792

88-
foreign import _newBuilder :: forall e. Aff (selenium :: SELENIUM|e) Builder
89-
foreign import _build :: forall e. Builder -> Aff (selenium :: SELENIUM|e) Driver
93+
foreign import _newBuilder :: forall e. Aff (selenium :: SELENIUM|e) Builder
94+
foreign import _build :: forall e. Builder -> Aff (selenium :: SELENIUM|e) Driver
9095

9196
foreign import _browser :: Fn2 Builder String Builder
9297
foreign import _forBrowser :: Fn4 Builder String String String Builder
9398
foreign import _usingServer :: Fn2 Builder String Builder
9499
foreign import _setScrollBehaviour :: Fn2 Builder ScrollBehaviour Builder
100+
foreign import _withCapabilities :: Fn2 Builder Capabilities Builder

0 commit comments

Comments
 (0)