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