如何让 Cucumber 针对 Selenium 和无头浏览器运行相同的步骤

发布于 2024-07-22 19:32:05 字数 241 浏览 3 评论 0原文

我一直在使用 Cucumber 测试 Web 应用程序,目前我已经设置了许多步骤来使用 Culerity 运行。 这很有效,但有时在 Selenium 中运行完全相同的故事会更好。

我看到两种可能有效的方法:

  1. 编写每个步骤,以便它根据某些全局变量的值适当地执行该步骤。
  2. 拥有单独的步骤定义文件,并以某种方式选择性地包含正确的文件。

实现此目的的首选方法是什么?

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:

  1. Writing each step so that it performs the step appropriately depending on the value of some global variable.
  2. Having separate step definition files and somehow selectively including the correct one.

What is the preferred method for accomplishing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

_失温 2024-07-29 19:32:06

您可以安排测试在 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

谎言月老 2024-07-29 19:32:05

第三个选项:查看 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.

路还长,别太狂 2024-07-29 19:32:05

嗨,你看过水豚吗? 它将允许您使用各种网络驱动程序,并且还允许您测试与 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文