{"action":"created","issue":{"url":"https://api.github.com/repos/kallisti-dev/hs-webdriver/issues/83","labels_url":"https://api.github.com/repos/kallisti-dev/hs-webdriver/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/kallisti-dev/hs-webdriver/issues/83/comments","events_url":"https://api.github.com/repos/kallisti-dev/hs-webdriver/issues/83/events","html_url":"https://github.com/kallisti-dev/hs-webdriver/issues/83","id":121723440,"number":83,"title":"Click the button with a native JS ","user":{"login":"denisshevchenko","id":5082435,"avatar_url":"https://avatars.githubusercontent.com/u/5082435?v=3","gravatar_id":"","url":"https://api.github.com/users/denisshevchenko","html_url":"https://github.com/denisshevchenko","followers_url":"https://api.github.com/users/denisshevchenko/followers","following_url":"https://api.github.com/users/denisshevchenko/following{/other_user}","gists_url":"https://api.github.com/users/denisshevchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/denisshevchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denisshevchenko/subscriptions","organizations_url":"https://api.github.com/users/denisshevchenko/orgs","repos_url":"https://api.github.com/users/denisshevchenko/repos","events_url":"https://api.github.com/users/denisshevchenko/events{/privacy}","received_events_url":"https://api.github.com/users/denisshevchenko/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/kallisti-dev/hs-webdriver/labels/question","name":"question","color":"cc317c"},{"url":"https://api.github.com/repos/kallisti-dev/hs-webdriver/labels/server-side","name":"server-side","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-12-11T14:57:37Z","updated_at":"2015-12-21T00:59:38Z","closed_at":null,"body":"Hi!\r\n\r\nI need to click some button, but not with a `click` function, but with a native JS. I see a special function for this task, `executeJS`. So this is my code:\r\n\r\n```haskell\r\n    ...\r\n    button <- findElement . ById $ \"clearCart\"\r\n    info <- elemInfo button\r\n    executeJS [JSArg info] \"arguments[0].click();\"\r\n    ...\r\n```\r\n\r\nBut I got a runtime error:\r\n\r\n```bash\r\nBadJSON \"when expecting a (), encountered Null instead\"\r\n```\r\n\r\nHow can I fix it?"},"comment":{"url":"https://api.github.com/repos/kallisti-dev/hs-webdriver/issues/comments/166169430","html_url":"https://github.com/kallisti-dev/hs-webdriver/issues/83#issuecomment-166169430","issue_url":"https://api.github.com/repos/kallisti-dev/hs-webdriver/issues/83","id":166169430,"user":{"login":"kallisti-dev","id":1530244,"avatar_url":"https://avatars.githubusercontent.com/u/1530244?v=3","gravatar_id":"","url":"https://api.github.com/users/kallisti-dev","html_url":"https://github.com/kallisti-dev","followers_url":"https://api.github.com/users/kallisti-dev/followers","following_url":"https://api.github.com/users/kallisti-dev/following{/other_user}","gists_url":"https://api.github.com/users/kallisti-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/kallisti-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kallisti-dev/subscriptions","organizations_url":"https://api.github.com/users/kallisti-dev/orgs","repos_url":"https://api.github.com/users/kallisti-dev/repos","events_url":"https://api.github.com/users/kallisti-dev/events{/privacy}","received_events_url":"https://api.github.com/users/kallisti-dev/received_events","type":"User","site_admin":false},"created_at":"2015-12-21T00:59:38Z","updated_at":"2015-12-21T00:59:38Z","body":"As far as I'm aware you can actually just pass an `Elemen~ directly as a `JSArg`, so something like this should work:\r\n\r\n```\r\nclickJS :: Element -> WD ()\r\nclickJS e = executeJS [JSArg e] \"arguments[0].click();\"\r\n```\r\nWebDriver handles this as a special case and will automatically convert the `Element` reference to its relevant DOM object. Likewise, if you return a DOM object it will automatically be converted to an `Element` reference."}}