在cloud9ide中的Watir-webdriver宝石

时间:2014-08-15 14:37:30

标签: watir-webdriver cloud9-ide

以下是我在尝试运行基本的watir测试脚本时在Cloud9 IDE中收到的错误

require 'rubygems'
require 'watir-webdriver'
browser = Watir::Browser.new :firefox
browser.goto 'http://apple.com'

- BEGIN ERROR -

/usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/firefox/binary.rb:120:in `path': Could not find Firefox binary (os=linux). Make sure Firefox is installed or set the path manually with Selenium::WebDriver::Firefox::Binary.path= (Selenium::WebDriver::Error::WebDriverError)                                                     
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/firefox/binary.rb:53:in `execute'                                              
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/firefox/binary.rb:34:in `start_with'                                           
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/firefox/launcher.rb:70:in `start_silent_and_wait'                              
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/firefox/launcher.rb:35:in `block in launch'                                    
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'                                          
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'                                             
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/firefox/bridge.rb:24:in `initialize'                                           
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/common/driver.rb:31:in `new'                                                   
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/common/driver.rb:31:in `for'                                                   
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver.rb:67:in `for'                                                                 
    from /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/watir-webdriver-0.6.10/lib/watir-webdriver/browser.rb:46:in `initialize'                                                        
    from /home/ubuntu/workspace/test_puppies/first_script.rb:3:in `new'                                                                                                             
    from /home/ubuntu/workspace/test_puppies/first_script.rb:3:in `<main>'      

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。经过大量的反复试验后,我发现正在运行Install firefox and xvfb: sudo apt-get install firefox xvfb为我修复它。

我应该注意,我正在使用您在上面提到的headless宝石以及watirwebdriver.com网站上的此代码。

require 'watir-webdriver'
require 'headless'
headless = Headless.new
headless.start
b = Watir::Browser.start 'www.google.com'
puts b.title
b.close
headless.destroy