[Haskell-cafe] webdriver and click via executeJS

John Lenz wuzzeb at gmail.com
Fri Dec 11 18:37:18 UTC 2015


I have this problem all the time and it is pretty anoying. The problem is
in parsing the return value. The javascript is returning null but the
executeJS is returning `()`.  The aeson instance for `()` does not parse
null.  What I do is something like

someOper :: WD ()
    ret <- executeJS [...] "...]
    maybe (return ()) return ret -- parse value from executeJS as Maybe ()

On Fri, Dec 11, 2015 at 11:48 AM, Denis Shevchenko <haskell at dshevchenko.biz>
wrote:

> Hi there!
>
> I use `webdriver` package for test automation with PhantomJS. And I need
> to click some button, but not with a `click` function, but with a native
> JS. I see a special function for such a task, `executeJS`, in the module
> `Test.WebDriver.Commands`. So this is my code:
>
>     ...
>     button <- findElement . ById $ "clearCart"
>     info <- elemInfo button
>     executeJS [JSArg info] "arguments[0].click();"
>     ...
>
> But I got a runtime error:
>
> BadJSON "when expecting a (), encountered Null instead"
>
> How can I fix it?
>
> - Denis
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151211/05be4b2a/attachment.html>


More information about the Haskell-Cafe mailing list