从 Cucumber/Capybara 测试执行 JavaScript
Selenium 似乎有一个名为 JavascriptExecutor 的功能,可以直接在页面上执行 JavaScript。然而,我的黄瓜/水豚测试似乎没有这样的东西。如何从我的 Cucumber 测试中执行任意 JavaScript?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Capybara 有两种方法来执行 javascript #execute_script 和 #evaluate_script。
两者都可以在以下位置找到: http://rubydoc.info/github/jnicklas /capybara/master/Capybara/Selenium/Driver
但是,请注意自述文件对上述方法有这样的声明:
请参阅 http://rubydoc.info /github/jnicklas/capybara/master/file/README.md。
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:
See http://rubydoc.info/github/jnicklas/capybara/master/file/README.md.