watir-rspec是要与watir还是watir-webdriver一起工作?
我目前正在使用watir和rspec。
我正在尝试设置watir-rspec,这样我就可以使用html格式化程序并拍摄截图并将它们嵌入到我的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发布于 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的教程
https://stackoverflow.com/questions/16906455
复制相似问题