在没有浏览器的情况下将 Selenium IDE 测试转换为 rspec 中的 运行

Converting Selenium IDE tests to run in rspec without browser

我们有一个 rails 应用程序,一些用户使用 Selenium IDE firefox 扩展来 record/create 一些测试。我们希望能够将这些测试集成到我们的自动化测试代码库中。

我知道 Selenium IDE 具有导出测试用例的能力,但是将这些测试转换成 rspec 无需浏览器就可以 运行 的东西的最简单方法是什么(或无头)?

I understand that Selenium IDE has the ability to export test cases, but what is the easiest way to convert these tests into something that rspec can run without a browser (or headless)?

Selenium IDE 只是 Firefox 的插件。 我相信,您可以在另一个 language/way 上执行相同的步骤。 但是为此你需要有另一个代码。 Selenium Web Driver 的代码可以作为 phantomJS 与无头浏览器一起使用。而且很容易。 但是 Selenium IDE 代码仅适用于 Firefox IDE 插件。

顺便说一下,很难维护使用 IDE 编写的测试。我相信,最好在您的案例中使用 Selenium WebDriver 重写所有测试。它会更容易和更快。 (例如,您可以为此使用页面对象模型)

我都用过。这是您可以做的

  • 使用 rspec webdriver 格式导出文件
  • 调整在 selenium 中可能使用的变量或本地文件存储,以便使用 rspec 有意义。这完全取决于您的使用情况。

这是一个经历的过程:

Select你要导出的测试(也可以导出整个套件) 导出为 rspec webdriver 打开生成的文件

根据需要进行调整,例如将常用项目移动到 spec_helper.rb 并确保它包含在内。

将文件放在 rspec 文件夹中,例如spec/views 并确保 spec_helper 包括它们。