2011-03-16 4 views
1

는 기본적으로 난 그냥 레일 3에 사용 셀레늄을 배우기 시작, 내가 셀레늄 IDE 시작 나는이 스크립트를 실행하기 전에 RSpec에 형식LoadError 셀레늄을 사용하여 :로드 해당 파일 - 스펙

에서 스크립트를 생성 나는 selenium-client, Selenium, selenium-railsselenium-webdriver

에 대한 보석을 설치하지만이 스크립트를 실행하는 RSpec에 명령을 사용하여, 나는이

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' 

내가 검색하는 것을 시도했다 있어요 대답, 내 주변에있는 유일한 사례는 누구도 아직 대답하지 않은 Selenium Can't Find 'spec' Folder입니다.

누군가 제가 미리 감사드립니다.

답변

1

먼저 나는

둘째, 나는

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

을 제거하고 spec_helper은 사양 폴더

I에 포함되어

require 'spec_helper' 

을 추가 정말 유용 Cucumber + Webrat + Selenium guide 발견 또한 모든 메소드를 제거했습니다. append_after

기본적으로 이제는 테스트 케이스가 실행 가능합니다. 이것은 최선의 해결책은 아니지만 지금까지 내가 한 것입니다.

P.S : 나뿐만 아니라이에 문제가 있어요 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 
2

와 서버를 http://seleniumhq.org/download/에서 셀레늄 서버를 다운로드하고 실행해야합니다. 그러나이 독립 실행 형 및 레일 3 프로젝트 안 실행하려면 노력하고있어. 그러나 나는 을 시도하여 루비 1.9.2를 사용하려고합니다.

실제로 IIS/ASP 웹 사이트를 점진적으로 레일로 변환하려고하고 있습니다. 첫 번째 단계는 완벽하게 훌륭한 "Selenese"세트의 테스트 스위트를 RSpec으로 내보내고 루비 등을 사용하여 실행하는 것이 었습니다. 저는 루비/레일스 세계에 익숙하지 않아 매우 실망 스럽습니다. 몇 시간 일할 것이라고 생각했던 것은 일로 바뀌 었습니다. ...

나는 비슷한 전략을 따랐습니다. 그러나, 나는 단지 보석을 모두 제거하고 require "selenium/client"을 제외한 명세서를 요구합니다. 또한 append_afterafter으로 변경했습니다. append_after 메서드는 selenium/rspec/spec_helper 파일에 정의되어 있습니다 (lib를 검사했습니다).

나는 웹 검색 시간과 시간을 소비하고 난 왜 require "selenium/rspec/spec_helper" 문이 실패에 같은 답을 찾을 수 없습니다 - 무엇인가라는이 spec (나는 RSpec에 호출 할 무엇을 사용이 생각 하는)없는 것 같다 .

내가 생각하기에 작동하지만 일부 기능이 누락되었습니다. spec_helper은 캡처 시스템 상태 및 기타 유용한 기능을 처리하는 것 같습니다.

귀하의spec_helper 파일에 무엇을 넣는 지 알고 싶습니다. 게시 할 수 있습니까?

+0

Rspec이 설치되어 있고,'rils generate rspec : install'을 실행하여 프로젝트 폴더 아래 spec 폴더를 생성했습니다. 'spec_helper' 파일은이 파일에 포함되어 있으며, 필자의 대답은 http://stackoverflow.com/questions/5330867/loaderror-when-using-selenium-no-such-file-to-load-spec입니다./5341873 # 5341873 – Souloikj

+0

spec_helper 설명에 감사드립니다. 비록이 하이브리드 (레일/IIS) 사이트의 추가 개발을 위해 오이와 RSpec을 사용하려고합니다. Selenium은 RSpec뿐만 아니라 테스트/유닛으로 변환 할 수 있기 때문에 로우 테크와 테스트/유닛을 사용하기로 결정했습니다. 기존의 Selenium 테스트는 "RSpec-like"가 아닌 "test/unity"가 더 많기 때문에 괜찮습니다. 이렇게하면 루비 또는 플롭으로 완전히 독립 실행 형 테스트를 실행할 수 있습니다. 레이크 앱 구조에서 레이크로 실행할 수 있습니다. – danv

4

문제는 귀하의 Rspec 버전입니다. Selenium gem은 Rspec 1.2.8 이상을 찾고 있지만 Rspec은 의 2.0 클래스 구조로 변경되었습니다. 그것은 당신의 문제를 해결해야

gem install rspec -v 1.3.1 

: 당신이 RSpec에 다음의 현재 버전을 제거 경우 셀레늄은 RSpec에 2에 더 이상 존재하지 않는 파일, 클래스 및 방법을 찾고있다. 자동화에서 Rspec을 다른 무언가로 사용한다면, 이것은 실행 가능한 옵션이 아닐 수도 있습니다.

관련 문제