如何让 Cucumber 针对 Selenium 和无头浏览器运行相同的步骤
我一直在使用 Cucumber 测试 Web 应用程序,目前我已经设置了许多步骤来使用 Culerity 运行。 这很有效,但有时在 Selenium 中运行完全相同的故事会更好。
我看到两种可能有效的方法:
- 编写每个步骤,以便它根据某些全局变量的值适当地执行该步骤。
- 拥有单独的步骤定义文件,并以某种方式选择性地包含正确的文件。
实现此目的的首选方法是什么?
I've been doing some work testing web applications with Cucumber and I currently have a number of steps set up to run with Culerity. This works well, but there are times when it would be nice to run the exact same stories in Selenium.
I see two possible approaches that may work:
- Writing each step so that it performs the step appropriately depending on the value of some global variable.
- Having separate step definition files and somehow selectively including the correct one.
What is the preferred method for accomplishing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我想这就是您正在寻找的人。 http://robots.thoughtbot.com/post/1658763359/thoughtbot -和圣杯
I think this is the one you are looking for. http://robots.thoughtbot.com/post/1658763359/thoughtbot-and-the-holy-grail
您可以安排测试在 Jenkins 中运行。 本地机Jenkins软件是开源的。 您可以在 Jenkins 中获取 Cucumber 插件,以便您可以在持续测试运行的基础上实现向项目报告部分
You can schedule the tests to run in Jenkins. Local machine Jenkins software is open source. You can get cucumber plugin in Jenkins so that you can achieve reporting part to your project on top of continuous test run
第三个选项:查看 Culerity 是否实现了 Webrat API。 它的 README 文件显示:“Culerity 让您(...)重用现有的 Webrat-样式步骤定义”。 但找不到更多的东西。 理想情况下,您可以使用配置选项或命令行参数切换后端,而无需触及步骤定义。
当然,这只有在您不测试 Javascript 时才有效,Culerity 支持 JavaScript,但 Webrat 不支持。
Third option: See if Culerity implements the Webrat API. Its README file says: "Culerity lets you (...) reuse existing Webrat-Style step definitions". Couldn't find much more than that though. Ideally, you would be able to switch backends with a config option or command-line argument without having to touch the step definitions.
Of course this would only work if you're not testing Javascript, which Culerity supports, but Webrat doesn't.
嗨,你看过水豚吗? 它将允许您使用各种网络驱动程序,并且还允许您测试与 javascript 相关的功能。
HI, have you looked at Capybara? It will allow you to use a variety of web drivers, and will allow you to test javascript-related features as well.