Selenium Can't Find 'spec' Folder

2019-07-01 18:51发布

So I'm attempting to set up my local system to help finish off an existing project from an employer who uses only rails. They want me to primarily focus on rspec testing as the project is nearly functional and I need to flesh out the things they've missed. However, I cannot get 'rake spec' to build my test folder. As it is, the test folder contains a few basic user login tests using Selenium (I didn't write them). Here is the trace from the error:

/opt/local/lib/ruby/gems/1.8/gems/selenium-client-1.2.18/lib/selenium/rspec/spec_helper.rb:2:in 'require': no such file to load -- spec (LoadError)
from /opt/local/lib/ruby/gems/1.8/gems/selenium-client-1.2.18/lib/selenium/rspec/spec_helper.rb:2
from /Users/cliffhess/ampms/spec/integration/user_registration_name_not_blank_spec.rb:5:in 'require'
from /Users/cliffhess/ampms/spec/integration/user_registration_name_not_blank_spec.rb:5
from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in 'load'
from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in 'load_spec_files'
from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in 'map'
from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in 'load_spec_files'
from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:18:in 'run'
from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in 'run_in_process'
from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in 'run'
from /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in 'autorun'
from /opt/local/lib/ruby/gems/1.8/bin/rspec:19
rake aborted!

As it is, I'm pretty sure I understand the problem(maybe?). Line 2 in selenium-clients's spec_helper.rb says require 'spec' which, if I'm not mistaken, is saying that selenium-client should contain a folder called spec which contains all of its rspec stuff. selenium-client does not have this folder, so I'm a little bit confused as to how its supposed to require the folder in the first place. If I change the line to require 'rspec', there are numerous other references to things within this imaginary spec folder that will also cause rake to abort.

I'm running Ruby 1.8.7, Rails 3.0.3, and the latest version of selenium. Any help would be amazing, I've been stuck googling this problem for over a day now and haven't been able to come up with a fix.

1条回答
做个烂人
2楼-- · 2019-07-01 19:16

I had the same issue you had, and I tried a few things to make it runnable, so I'm just copy my answers from my question - LoadError when using Selenium: no such file to load -- spec


First I found Cucumber + Webrat + Selenium guide which is really useful

Second, I removed

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

And added

require 'spec_helper'

Where spec_helper is the contained in the spec folder

I also removed all the methods that is append_after

Basically now the test cases runnable, this is not the best solution, but it is what I did do so far.

P.S: need to download the Selenium server from http://seleniumhq.org/download/ and run the server with java -jar selenium-server-standalone-2.0b2.jar

查看更多
登录 后发表回答