This repository was archived by the owner on Jan 17, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -180,10 +180,20 @@ exports.getCssValue = function(el) {
180
180
} ;
181
181
} ;
182
182
183
- exports . getAttribute = function ( el ) {
184
- return function ( str ) {
185
- return function ( cb , eb ) {
186
- return el . getAttribute ( str ) . then ( cb ) . thenCatch ( eb ) ;
183
+ exports . _getAttribute = function ( nothing ) {
184
+ return function ( just ) {
185
+ return function ( el ) {
186
+ return function ( str ) {
187
+ return function ( cb , eb ) {
188
+ return el . getAttribute ( str ) . then ( function ( attr ) {
189
+ if ( attr === null ) {
190
+ cb ( nothing ) ;
191
+ } else {
192
+ cb ( just ( attr ) ) ;
193
+ }
194
+ } ) . thenCatch ( eb ) ;
195
+ } ;
196
+ } ;
187
197
} ;
188
198
} ;
189
199
} ;
Original file line number Diff line number Diff line change @@ -145,7 +145,14 @@ foreign import executeStr :: forall e. Driver -> String -> Aff (selenium :: SELE
145
145
foreign import sendKeysEl :: forall e . String -> Element -> Aff (selenium :: SELENIUM |e ) Unit
146
146
foreign import clickEl :: forall e . Element -> Aff (selenium :: SELENIUM |e ) Unit
147
147
foreign import getCssValue :: forall e . Element -> String -> Aff (selenium :: SELENIUM |e ) String
148
- foreign import getAttribute :: forall e . Element -> String -> Aff (selenium :: SELENIUM |e ) String
148
+ foreign import _getAttribute :: forall e a . Maybe a -> (a -> Maybe a ) ->
149
+ Element -> String -> Aff (selenium :: SELENIUM |e ) (Maybe String )
150
+
151
+ -- | Tries to find an element starting from `document` will return `Nothing` if there
152
+ -- | is no element can be found by locator
153
+ getAttribute :: forall e . Element -> String -> Aff (selenium :: SELENIUM |e ) (Maybe String )
154
+ getAttribute = _getAttribute Nothing Just
155
+
149
156
foreign import getText :: forall e . Element -> Aff (selenium :: SELENIUM |e ) String
150
157
foreign import isDisplayed :: forall e . Element -> Aff (selenium :: SELENIUM |e ) Boolean
151
158
foreign import isEnabled :: forall e . Element -> Aff (selenium :: SELENIUM |e ) Boolean
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ isEnabled = lift <<< S.isEnabled
152
152
getCssValue :: forall e o . Element -> String -> Selenium e o String
153
153
getCssValue el key = lift $ S .getCssValue el key
154
154
155
- getAttribute :: forall e o . Element -> String -> Selenium e o String
155
+ getAttribute :: forall e o . Element -> String -> Selenium e o ( Maybe String )
156
156
getAttribute el attr = lift $ S .getAttribute el attr
157
157
158
158
getText :: forall e o . Element -> Selenium e o String
You can’t perform that action at this time.
0 commit comments