当我运行 Cucumber 时,出现以下错误:
undefined method `visit' for "default":String (NoMethodError)
C:/Users/user/.pik/rubies/Ruby-193-p194/lib/ruby/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/session.rb:157:in `visit'
C:/Users/user/.pik/rubies/Ruby-193-p194/lib/ruby/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/dsl.rb:161:in `visit'
D:/Andrey/project/features/support/env.rb:33:in `basicAuth'
D:/Andrey/project/features/support/env.rb:54:in `addHost'
D:/Andrey/project/features/support/env.rb:95:in `Before'
当调用Capybara.visit("http://www.google.com")
和
undefined method `browser' for "default":String (NoMethodError)
D:/Andrey/project/features/support/env.rb:105:in `After'
调用时page.driver.browser.save_screenshot("screenshot.png")
和许多类似的错误。似乎到处都无法使用水豚的方法。
但是当我运行时Capybara.methods.sort
,我会得到包含访问的输出。
为什么会这样?
更新: 问题出在 env.rb 中。它包含代码:
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end
end
如果我将其更改为:
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :firefox)
end
end
然后它工作。
以前的代码有什么问题?