如何轻松切换Webrat和Selenium?
请告诉我如何在 Webrat 和 Selinium 之间轻松切换? Selinium 需要更长的时间,因为它通过打开真实的浏览器进行模拟。在某些情况下,我不需要这个,只需要 Webrat,在命令行中显示结果就很好而且更快。有没有办法配置 Cucumber 在 Webrat 和 Selenium 之间切换?
Please let me know how can I easily switch between Webrat and Selinium? Selinium takes longer as it simulates by opening the real browser. In some cases I do not need this and just Webrat, showing results in command line is just fine and faster. Is there anyway to configure cucumber to switch between Webrat and Selenium??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有多种方法可以实现这一点。但最简单的是:
用@selenium标记单个文件/场景以调用selenium,然后使用@javascript作为默认驱动程序,如果我没记错的话,它使用webrat作为默认驱动程序。
仅当您直接调用 Selenium 时才会调用它。
There are a number of ways to accomplish this. But the easiest is:
Tag individual files/Scenarios with @selenium to invoke selenium and then use @javascript as your default driver which uses webrat as the default driver, if I recall correctly.
This will only call Selenium when you invoke it directly.
Capybara 被设计为 webrat 的替代品,它支持多个后端驱动程序(包括 Selenium),并且您即使在测试运行期间也可以在它们之间切换。例如,也许您希望大多数测试都能快速运行,但有些测试需要 ajax 测试/跨浏览器测试,对于这些测试,您可以切换到 Selenium。
Capybara is designed to be a webrat replacement, and it supports multiple back-end drivers (including Selenium) and you can switch between them, even during a test run. For example, maybe you want most of your tests to run fast but some require ajax testing / cross-browser testing and for those you can switch to Selenium.