Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm using Selenium with rspec on my project and generate code from a custom formatter for Selenium IDE. </p> <p>There is many selenium for rails but i success using Selenium-RC <a href="http://seleniumhq.org/download/" rel="noreferrer">http://seleniumhq.org/download/</a> , so download to your pc.</p> <p>Here are my steps:</p> <ol> <li>Unzip and run> java -jar selenium-server.jar</li> <li>Open selenium-client-ruby, read the doc, follow it you will get success! </li> <li>gem install rspec, rspec-rails version 1.2.6 (it not, you need to comment version restrict of selenium-client source code)</li> <li>gem install selenium-client</li> <li>Open Selenium-IDE (Firefox of course), Open Options -> Options -> Formats</li> <li>Click Add, and paste this code in <a href="http://www.techdarkside.com/rspec_export.txt" rel="noreferrer">http://www.techdarkside.com/rspec_export.txt</a></li> </ol> <p>Now, You just export spec to your spec folder for me, I use spec/features/xxxx_spec.rb see code below.</p> <p>Very similar approach can find at <a href="http://texagon.blogspot.com/2007/06/lets-play-selenium-part-one.html" rel="noreferrer">here</a></p> <p>For webrat+cucumber, the latest <a href="http://www.pragprog.com/titles/achbd/the-rspec-book" rel="noreferrer">Rspec book</a> will give all you need. (They don't have selenium + cucumber chapter finish yet)</p> <p>example </p> <pre><code> require 'rubygems' gem "rspec", "=1.2.6" gem "selenium-client", "&gt;=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 =&gt; "localhost", :port =&gt; 4444, :browser =&gt; "*firefox", :url =&gt; "http://www.google.com", :timeout_in_second =&gt; 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 =&gt; :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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload