【问题标题】:watir-rspec: watir or watir-webdriver?watir-rspec:watir 还是 watir-webdriver?
【发布时间】:2015-01-05 17:37:09
【问题描述】:

watir-rspec 是否适用于 watir 或 watir-webdriver?

我目前正在使用 watir 和 rspec。

我正在尝试设置 watir-rspec,以便我可以使用 html-formatter 并截取屏幕截图并将它们嵌入到我的 html 日志文件中。

我已阅读 github 上的自述文件,其中声明“将这些行添加到您的 spec_helper.rb 文件中”

我只是不确定它指的是哪里和哪个 spec_helper.rb 文件。

它声明要添加的代码如下:


        RSpec.configure do |config|
          # Add Watir::RSpec::HtmlFormatter to get links to the screenshots, html and
          # all other files created during the failing examples.
          config.add_formatter('documentation')
          config.add_formatter(Watir::RSpec::HtmlFormatter)

          # Open up the browser for each example.
          config.before :all do
            @browser = Watir::Browser.new
          end

          # Close that browser after each example.
          config.after :all do
            @browser.close if @browser
          end

          # Include RSpec::Helper into each of your example group for making it possible to
          # write in your examples instead of:
          #   @browser.goto "localhost"
          #   @browser.text_field(:name => "first_name").set "Bob"
          #
          # like this:
          #   goto "localhost"
          #   text_field(:name => "first_name").set "Bob"
          #
          # This needs that you've used @browser as an instance variable name in
          # before :all block.
          config.include Watir::RSpec::Helper
        end

【问题讨论】:

    标签: rspec watir watir-webdriver


    【解决方案1】:

    由于 watir-classic 和 watir-webdriver 共享相同的 API,因此 watir-rspec 应该兼容两者。

    spec_helper.rb 通常是您为 rspec 套件编写任何配置的地方。然后,您的每个规范文件都需要此文件。

    例如,您可以看到 watirspec 中使用了 spec_helper.rb,这是 watir-classic 和 watir-webdriver 的大部分规范 - 请参阅 https://github.com/watir/watirspec

    一些教程可能会帮助你理解spec_helper.rb

    【讨论】:

      猜你喜欢
      • 2012-03-06
      • 2018-04-01
      • 2011-10-28
      • 1970-01-01
      • 1970-01-01
      • 2013-04-11
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      相关资源
      最近更新 更多