LoadError when using Selenium: there is no such file to load - spec

Basically, I just started learning about using Selenium on Rails 3, I started with the Selenium IDE and generated a script in RSpec format

Before running this script, I found precious stones selenium-client, Selenium, selenium-railsandselenium-webdriver

But since I use the rspec command to run this script, I got

C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:58:in `require': no such file to load -- spec (LoadError)
    from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:58:in `rescue in require'
    from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-client-1.2.18/lib/selenium/rspec/spec_helper.rb:2:in `<top (required)>'
    from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from C:/Users/qsang/Desktop/Code/NextBigThing/spec/Selenium/create_new_user.rb:5:in `<top (required)>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `block in load_spec_files'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `map'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load_spec_files'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:18:in `run'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `block in autorun'

I tried to find the answer, the only case I found is close to mine, Selenium cannot find the "spec" Folder , which no one has answered yet.

Can someone help me, thanks in advance.

+1
source share
3 answers

Cucumber + Webrat + Selenium guide,

-,

require "selenium/rspec/spec_helper"
require "spec/test/unit"

require 'spec_helper'

spec_helper spec

, append_after

, , , .

P.S: Selenium http://seleniumhq.org/download/ java -jar selenium-server-standalone-2.0b2.jar


spec_helper

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  # == Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  config.fixture_path = "#{::Rails.root}/spec/fixtures"

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true.
  config.use_transactional_fixtures = true
end
+1

Rspec. Selenium Rspec 1.2.8 , Rspec 2.0. Selenium , , Rspec 2. Rspec an, :

gem install rspec -v 1.3.1

. Rspec - , .

+4

. , rails3. ruby ​​1.9.2.

- IIS/ASP, . "" , RSpec .. /, . , , , ...

. , require "selenium/client". append_after after. append_after selenium/rspec/spec_helper ( lib).

I spent hours and hours searching the Internet, and I can’t find an answer about why the operator require "selenium/rspec/spec_helper"fails - it seems that something called spec(which, it seems to me, is used to call RSpec) is missing.

It works for me, I think, but it lacks some functions. spec_helperseems to handle system state and other useful features.

I am interested to know what you have embedded in your spec_helper file. Could you post it?

+2
source

All Articles