我有简单的 ruby+watir-webdriver 示例:
#!/usr/bin/env ruby
require "rubygems"
require 'watir-webdriver'
browser = Watir::Browser.new
...
# do something
...
browser.close
当我手动运行此文件时:
/path/to/my/ruby/example.rb
它工作正常。当我将其放入 cronjob 时,它不起作用...我已将 cronjob 更改为
ruby /path/to/my/ruby/example.rb
但再次无法正常工作。任何想法如何定位问题?
@Kevin 这里是输出:
/home/lks/.rvm/gems/ruby-1.9.3-p194/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/firefox/launcher.rb:77:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from /home/lks/.rvm/gems/ruby-1.9.3-p194/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/firefox/launcher.rb:37:in `block in launch'
from /home/lks/.rvm/gems/ruby-1.9.3-p194/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
from /home/lks/.rvm/gems/ruby-1.9.3-p194/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
from /home/lks/.rvm/gems/ruby-1.9.3-p194/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/firefox/bridge.rb:19:in `initialize'
from /home/lks/.rvm/gems/ruby-1.9.3-p194/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/common/driver.rb:31:in `new'
from /home/lks/.rvm/gems/ruby-1.9.3-p194/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/common/driver.rb:31:in `for'
from /home/lks/.rvm/gems/ruby-1.9.3-p194/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver.rb:63:in `for'
from /home/lks/.rvm/gems/ruby-1.9.3-p194/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:35:in `initialize'