RSpec Error Regarding Selenium-Webdriver

2019-06-22 05:36发布

问题:

Trying to get through Michael Hartl's tutorial; encountering issues here.

I've just created the application.

Here is what I am presented with when I run 'bundle exec rspec spec/requests/static_pages_spec.rb'

Corey-M-Kimball:sample_app coreymkimball$ bundle exec rspec spec/requests/static_pages_spec.rb
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in `require': cannot load such file -- zip/zip (LoadError)
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in `<top (required)>'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in `require'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common.rb:9:in `<top (required)>'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in `require'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver.rb:29:in `<top (required)>'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in `require'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium-webdriver.rb:1:in `<top (required)>'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /Users/coreymkimball/Canvi/sample_app/config/application.rb:12:in `<top (required)>'
    from /Users/coreymkimball/Canvi/sample_app/config/environment.rb:2:in `require'
    from /Users/coreymkimball/Canvi/sample_app/config/environment.rb:2:in `<top (required)>'
    from /Users/coreymkimball/Canvi/sample_app/spec/spec_helper.rb:3:in `require'
    from /Users/coreymkimball/Canvi/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
    from /Users/coreymkimball/Canvi/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
    from /Users/coreymkimball/Canvi/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
    from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

I can't figure out what the issue is.

Spec:

require 'spec_helper'

describe "Static pages" do

  describe "Home page" do

    it "should have the content 'Sample App'" do
      visit '/static_pages/home'
      expect(page).to have_content('Sample App')
    end
  end
end

Thanks.

回答1:

Rewrite your Gemfile. Change 'selenium-webdriver' to '~> 2.35.1', reinstall bundle and everything has to be OK!



回答2:

I think, the problem might be similar to this one: zip/zip (LoadError) - Breaking guard or rails 4.0 Seems like it's a bug in selenium-webdriver gem, that has beed solved in the latest versions. So try updating your Gemfile and your bundle.



回答3:

I used the above answer (by user Arsenii Prohorchik) and it worked for me. I noticed that the result of following his suggestion to rewite the gemfile caused the following changes when running "bundle update"

Installing rubyzip (0.9.9)
Installing websocket (1.0.7)
Installing selenium-webdriver (2.35.1)

This fixed the problem for me.