Selenium 找不到“规范"文件夹 [英] Selenium Can't Find 'spec' Folder
问题描述
所以我试图建立我的本地系统,以帮助完成一个只使用 Rails 的雇主的现有项目.他们希望我主要关注 rspec 测试,因为该项目几乎可以正常运行,我需要充实他们遗漏的东西.但是,我无法获得 'rake spec' 来构建我的测试文件夹.实际上,测试文件夹包含一些使用 Selenium 的基本用户登录测试(我没有编写它们).这是错误的跟踪:
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!
事实上,我很确定我理解这个问题(也许?).selenium-clients 的 spec_helper.rb 中的第 2 行说 require 'spec'
如果我没记错的话,它是说 selenium-client 应该包含一个名为 spec
的文件夹包含其所有的 rspec 内容.selenium-client 没有这个文件夹,所以我对它首先应该如何需要这个文件夹感到有点困惑.如果我将该行更改为 require 'rspec'
,则在这个虚构的 spec 文件夹中还有许多其他引用,这些内容也会导致 rake 中止.
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.
我正在运行 Ruby 1.8.7、Rails 3.0.3 和最新版本的 selenium.任何帮助都会很棒,我已经在谷歌上搜索这个问题超过一天了,一直没能想出解决办法.
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.
推荐答案
我遇到了和你一样的问题,我尝试了一些方法让它可以运行,所以我只是从我的问题中复制我的答案 -
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
首先我发现Cucumber + Webrat + Selenium 指南,这非常有用
First I found Cucumber + Webrat + Selenium guide which is really useful
其次,我删除了
require "selenium/rspec/spec_helper"
require "spec/test/unit"
并添加
require 'spec_helper'
其中 spec_helper
包含在 spec 文件夹中
Where spec_helper
is the contained in the spec folder
我还删除了 append_after
基本上现在测试用例可以运行了,这不是最好的解决方案,但这是我目前所做的.
Basically now the test cases runnable, this is not the best solution, but it is what I did do so far.
PS:需要从 http://seleniumhq.org/download/ 和使用 java -jar selenium-server-standalone-2.0b2.jar
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
这篇关于Selenium 找不到“规范"文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!