尝试运行一些Watir代码作为Rake任务,给我这个错误:
$ bundle exec rake update_market_rents:market_rents
DL is deprecated, please use Fiddle
(in C:/Users/310046998/sites/testpropinvest)
rake aborted!
LoadError: cannot load such file -- watir-webdriver
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
C:/Users/310046998/sites/testpropinvest/lib/tasks/update_market_rents.rake:10:in `block (2 levels) in <top (required)>'
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => update_market_rents:market_rents
(See full trace by running task with --trace)
代码:
namespace :update_market_rents do
desc "TODO"
task market_rents: :environment do
#watir code
require 'watir-webdriver'
Selenium::WebDriver::Firefox::Binary.path='C:\Program Files\Mozilla Firefox\firefox.exe'
browser = Watir::Browser.new :ff
#blah blah more code
browser.close
end
end
如果我使用$ ruby filename.rb
从命令提示符运行Watir代码,我没有问题。出于某种原因,当我尝试通过Rake命令运行它时,我得到上述错误。鉴于我认为代码单独工作,我正在努力寻找发生的事情。
我尝试添加require 'rubygems'
,但这不起作用。
答案 0 :(得分:0)
如果您使用的是Linux,请运行:
sudo apt-get install nodejs
在Mac上:
brew install node