首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >watir-rspec: watir还是watir-webdriver?

watir-rspec: watir还是watir-webdriver?
EN

Stack Overflow用户
提问于 2013-06-03 21:52:49
回答 1查看 1.4K关注 0票数 2

watir-rspec是要与watir还是watir-webdriver一起工作?

我目前正在使用watir和rspec。

我正在尝试设置watir-rspec,这样我就可以使用html格式化程序并拍摄截图并将它们嵌入到我的html日志文件中。

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

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

它要添加的代码如下:

代码语言:javascript
复制
        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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-04 03:15:36

由于watir-经典和watir-webdriver共享相同的API,所以watir-rspec应该与两者兼容。

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

例如,您可以看到watirspec中使用的spec_helper.rb,这是watir的大多数规范--经典的和watir-webdriver -参见https://github.com/watir/watirspec

一些可能帮助您理解spec_helper.rb的教程

  • http://blog.nicksieger.com/articles/2007/01/02/customizing-rspec/
  • http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-testing-with-rspec/
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16906455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档