2009-09-04 5 views
12

오랫동안 오이와 우리 브래지어를 사용 해왔다. 이제는 AJAX 상호 작용을 포함하는 동작을 작성해야하므로 Webrat 용 ​​Selenium 어댑터를 사용하려고 생각했습니다. 셀레늄 + webrat + 오이를 설치하고 구성하기위한 쉽고 업데이트 된 단계별 가이드를 알려줄 수 있습니까? 비 자바 스크립트 시나리오와 자바 스크립트 시나리오를 혼합 할 수 있기를 원합니다.Cucumber + Webrat + Selenium guide

답변

8

내 프로젝트에서 rspec과 함께 Selenium을 사용하고 Selenium IDE 용 사용자 정의 포매터에서 코드를 생성합니다.

레일에는 셀레늄이 많이 있지만 Selenium-RC http://seleniumhq.org/download/을 사용하면 성공하므로 PC에 다운로드하십시오.

  1. 의 압축을 풀고 실행> 자바 -jar 셀레늄 server.jar
  2. 당신이 성공을 얻을 것이다 셀레늄 - 클라이언트 루비의 문서를 읽고, 그 뒤에 열기 :

    여기 내 단계입니다!

  3. 보석이 RSpec을 설치, RSpec에 레일 버전 1.2.6
  4. 보석 셀레늄 클라이언트 물론
  5. 열기 셀레늄-IDE (파이어 폭스 설치 (그렇지, 당신은 버전 셀레늄 클라이언트 소스 코드의 제한 언급 할 필요)) 열기 옵션 -> 옵션 -> 포맷 나를 위해 당신의 사양 폴더에
  6. 추가를 클릭하고 지금 http://www.techdarkside.com/rspec_export.txt

에서이 코드를 붙여 넣습니다, 당신은 단지 수출 사양, 내가 사용하는 사양/기능/xxxx_spec.rb 아래 코드를 참조하십시오.

매우 유사한 접근 방식은 최신 Rspec book는 당신이 필요로하는 모든를 제공합니다 webrat + 오이를 들어 here

에서 찾을 수 있습니다.

예 (그들은 아직 셀레늄 + 오이 장 마감이없는)

require 'rubygems' 
gem "rspec", "=1.2.6" 
gem "selenium-client", ">=1.2.15" 
require "selenium/client" 
require "selenium/rspec/spec_helper" 

describe "Google Search" do 
    attr_reader :selenium_driver 
    alias :page :selenium_driver 

    before(:all) do 
     @selenium_driver = Selenium::Client::Driver.new \ 
      :host => "localhost", 
      :port => 4444, 
      :browser => "*firefox", 
      :url => "http://www.google.com", 
      :timeout_in_second => 60 
    end 

    before(:each) do 
    selenium_driver.start_new_browser_session 
    end 

    # The system capture need to happen BEFORE closing the Selenium session 
    append_after(:each) do 
    @selenium_driver.close_current_browser_session 
    end 

    it "can find Selenium" do 
    page.open "/" 
    page.title.should eql("Google") 
    page.type "q", "Selenium seleniumhq" 
    page.click "btnG", :wait_for => :page 
    page.value("q").should eql("Selenium seleniumhq") 
    page.text?("seleniumhq.org").should be_true 
    page.title.should eql("Selenium seleniumhq - Google Search") 
    page.text?("seleniumhq.org").should be_true 
      page.element?("link=Cached").should be_true 
    end 

end 
관련 문제