It appears that Selenium has a feature called JavascriptExecutor
which makes it possible to execute JavaScript directly on the page. However it appears that there is no such thing available to my Cucumber/Capybara tests. How can I execute arbitrary JavaScript from my Cucumber tests?
Capybara has two methods to execute javascript #execute_script and #evaluate_script. Both can be found at: http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Selenium/Driver
However, do note that the readme has this statement about the above methods:
For simple expressions, you can return the result of the script. Note that this may break with more complicated expressions:
See http://rubydoc.info/github/jnicklas/capybara/master/file/README.md.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With