<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Selenium Testing? Do Cross Browser Testing with Sauce Labs &#187; ruby</title>
	<atom:link href="http://saucelabs.com/blog/index.php/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://saucelabs.com/blog</link>
	<description></description>
	<lastBuildDate>Tue, 31 Jan 2012 20:58:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Video Demo: RSpec + Selenium + Sauce OnDemand</title>
		<link>http://saucelabs.com/blog/index.php/2010/10/video-demo-rspec-selenium-sauce-ondemand/</link>
		<comments>http://saucelabs.com/blog/index.php/2010/10/video-demo-rspec-selenium-sauce-ondemand/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 18:14:53 +0000</pubDate>
		<dc:creator>Ashley Wilson</dc:creator>
				<category><![CDATA[Webinars]]></category>
		<category><![CDATA[Cross Browser]]></category>
		<category><![CDATA[parallel testing]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Sauce Labs]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://saucelabs.com/blog/?p=2026</guid>
		<description><![CDATA[Thanks to all who tuned in to our live web demo last week, Using RSpec + Selenium to Test Your Ruby Builds Faster. Sauce Labs Developer Sean Grove walked attendees through the steps of writing an RSpec test and using it with Selenium, and then showed how to run that test across multiple browsers in [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to all who tuned in to our live web demo last week, <strong>Using RSpec + Selenium to Test Your Ruby Builds Faster</strong>. <a href="http://saucelabs.com">Sauce Labs</a> Developer Sean Grove walked attendees through the steps of writing an RSpec test and using it with Selenium, and then showed how to run that test across multiple browsers in the cloud using <a href="http://saucelabs.com/ondemand">Sauce OnDemand</a>. </p>
<p>For those of you who missed it, check out Sean&#8217;s sample code on Github (<a href="http://github.com/sgrove/rspec_sauce_webinar">http://github.com/sgrove/rspec_sauce_webinar</a>), and then follow along with the video below. We&#8217;re planning another Ruby-based webinar in the future, so make sure to subscribe to our blog&#8217;s <a href="http://saucelabs.com/blog/index.php/feed/">RSS feed</a> to stay up to date!</p>
<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="315" id="viddler_72df640f"><param name="movie" value="http://www.viddler.com/player/72df640f/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/72df640f/" width="437" height="315" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler_72df640f"></embed></object></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsaucelabs.com%2Fblog%2Findex.php%2F2010%2F10%2Fvideo-demo-rspec-selenium-sauce-ondemand%2F&amp;title=Video%20Demo%3A%20RSpec%20%2B%20Selenium%20%2B%20Sauce%20OnDemand" id="wpa2a_2"><img src="http://saucelabs.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://saucelabs.com/blog/index.php/2010/10/video-demo-rspec-selenium-sauce-ondemand/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RSpec + Selenium Demonstration 9/30 at 11 am PST</title>
		<link>http://saucelabs.com/blog/index.php/2010/09/rspec-selenium-demonstration-930-at-11-am-pst/</link>
		<comments>http://saucelabs.com/blog/index.php/2010/09/rspec-selenium-demonstration-930-at-11-am-pst/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 18:55:37 +0000</pubDate>
		<dc:creator>Ashley Wilson</dc:creator>
				<category><![CDATA[Webinars]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Cross Browser]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[selenium]]></category>

		<guid isPermaLink="false">http://saucelabs.com/blog/?p=1880</guid>
		<description><![CDATA[Join Sean Grove, senior developer at Sauce Labs, as he shows you how to take your RSpec tests and pit &#8216;em against the real world. RSpec is a Ruby framework that provides a Domain Specific Language that expresses executable examples of the expected behavior of your code. Learn how to launch and control real browsers [...]]]></description>
			<content:encoded><![CDATA[<p>Join Sean Grove, senior developer at <a href="http://saucelabs.com">Sauce Labs</a>, as he shows you how to take your RSpec tests and pit &#8216;em against the real world. RSpec is a Ruby framework that provides a Domain Specific Language that expresses executable examples of the expected behavior of your code.</p>
<p>Learn how to launch and control real browsers directly from RSpec tests using Selenium and <a href="http://saucelabs.com/ondemand">Sauce OnDemand</a>. In this<a href="https://www1.gotomeeting.com/register/330418728"> live video demontration</a> on Sept. 30 at 11 am PST, he&#8217;ll demonstrate and discuss:</p>
<p>    * Writing your first RSpec test<br />
    * Configuring it to use Selenium<br />
    * Cross-browser testing and spec parallelization</p>
<p>Be sure to stick around for the Q&#038;A following the presentation. <a href="https://www1.gotomeeting.com/register/330418728">Register Here!</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsaucelabs.com%2Fblog%2Findex.php%2F2010%2F09%2Frspec-selenium-demonstration-930-at-11-am-pst%2F&amp;title=RSpec%20%2B%20Selenium%20Demonstration%209%2F30%20at%2011%20am%20PST" id="wpa2a_4"><img src="http://saucelabs.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://saucelabs.com/blog/index.php/2010/09/rspec-selenium-demonstration-930-at-11-am-pst/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cucumber Sauce: Cross-browser testing in parallel</title>
		<link>http://saucelabs.com/blog/index.php/2010/09/cucumber-sauce-cross-browser-testing-in-parallel/</link>
		<comments>http://saucelabs.com/blog/index.php/2010/09/cucumber-sauce-cross-browser-testing-in-parallel/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 06:13:34 +0000</pubDate>
		<dc:creator>The Sauce Labs Team</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[cucumber sauce]]></category>
		<category><![CDATA[parallel testing]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://saucelabs.com/blog/?p=1871</guid>
		<description><![CDATA[I&#8217;ve been meaning to release a &#8220;standard&#8221; cucumber-in-parallel cross-browser project for awhile now, but I just got around to it this weekend. It&#8217;s called Cucumber Sauce. Highlights: Run your cucumber tests across different browsers all at the same time Browsers are configurable via a yaml file Multiple browser config files are easy to setup, and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to release a &#8220;standard&#8221; cucumber-in-parallel cross-browser project for awhile now, but I just got around to it this weekend. It&#8217;s called <a href="http://github.com/sgrove/cucumber_sauce">Cucumber Sauce</a>.</p>
<p><strong>Highlights</strong>:</p>
<ul>
<li><span style="font-size: 13.3333px;">Run your cucumber tests across different browsers all at the same time</span></li>
<li><span style="font-size: 13.3333px;">Browsers are configurable via a yaml file</span></li>
<li><span style="font-size: 13.3333px;">Multiple browser config files are easy to setup, and one can be passed in when running the rake task. Have a browsers_core.yml file to run while developing, and a browsers_full.yml to run before pushing to production</span></li>
<li><span style="font-size: 13.3333px;">Designed to run tests ultra-cleanly. Adds time overhead initially, but tests are all independent of one another, and can be made to run in parallel at the scenario level in the future. Follow this template or you&#8217;ll lose that ability to speed up your tests.</span></li>
</ul>
<p>Check it out at the <a href="http://github.com/sgrove/cucumber_sauce">Cucumber Sauce github repo</a>.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsaucelabs.com%2Fblog%2Findex.php%2F2010%2F09%2Fcucumber-sauce-cross-browser-testing-in-parallel%2F&amp;title=Cucumber%20Sauce%3A%20Cross-browser%20testing%20in%20parallel" id="wpa2a_6"><img src="http://saucelabs.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://saucelabs.com/blog/index.php/2010/09/cucumber-sauce-cross-browser-testing-in-parallel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up Cucumber + Webrat + Selenium</title>
		<link>http://saucelabs.com/blog/index.php/2010/06/setting-up-cucumber-webrat-selenium/</link>
		<comments>http://saucelabs.com/blog/index.php/2010/06/setting-up-cucumber-webrat-selenium/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 17:36:46 +0000</pubDate>
		<dc:creator>The Sauce Labs Team</dc:creator>
				<category><![CDATA[Featured Posts]]></category>
		<category><![CDATA[Sauce Offerings]]></category>
		<category><![CDATA[Selenium Knowledge]]></category>
		<category><![CDATA[Webinars]]></category>
		<category><![CDATA[Cross Browser Testing]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sauce ondemand]]></category>

		<guid isPermaLink="false">http://saucelabs.com/blog/?p=1141</guid>
		<description><![CDATA[There's quite a bit of information out there on setting up these disparate tools to work together, but a great deal of it is out of date. To clear things up a bit I've documented all of the gems and modifications necessary to get these great pieces of open source software up and running together. I'll be expanding this post with notes around the pitfalls as time goes on and various platform issues are discovered (I'm looking at you, Snow Leopard), but this should get most people up and running right away.
]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s quite a bit of information out there on getting these disparate tools to work together, but a great deal of it is out of date. To clear things up a bit, I&#8217;ve documented all the gems and modifications necessary to get these pieces of open source software up and running together. As time goes on, I&#8217;ll be expanding this blog post with notes about the pitfalls and various platform issues that may be discovered (I&#8217;m looking at you, Snow Leopard), but this should get most people up and running right away.</p>
<p>This is all using a clean <a href="http://www.rubyenterpriseedition.com/">REE</a> environment via the poorly named but wonderfully written <a href="http://rvm.beginrescueend.com/">rvm</a>, or Ruby Version Manager.</p>
<p>Gems you&#8217;ll need:<br />
<code><br />
gem install actionmailer actionpack activerecord activeresource activesupport builder cgi_multipart_eof_fix cucumber cucumber-rails daemons database_cleaner diff-lcs fastthread gem_plugin gherkin json json_pure mime-types mongrel net-ssh net-ssh-gateway nokogiri rack rack-test rails rake rdoc rest-client rspec rspec-rails Selenium selenium-client sqlite3-ruby term-ansicolor trollop webrat<br />
</code></p>
<p>Some of those are not strictly necessary, but simply nice to have, while others solved some unexpected problems with the bare necessities. I&#8217;ll prune this list as feedback comes in from people&#8217;s experiences.</p>
<p>Points to watch out for:<br />
Nokogiri: This was easily the worst on my Snow Leopard machine. It relies on the native libxml2, which had problems with 32/64 bit compatibility. No matter what I tried, errors kept coming up. I had to clean everything out with my MacPorts installation and force a universal installation.<br />
Webrat: The Selenium server jar that was included by default caused no end of headaches. I had to manually go in to the directory, remove the default server jar, and download the newest version from the <a href="http://seleniumhq.org/download/">seleniumhq</a> download page.</p>
<p>Once those are set up, you should be able to use Cucumber, Webrat, and Selenium together without too much headache. Then you can refer to our webinar video (which will be posted to the blog later this week) to learn how to use Cucumber to easily run Webrat and Selenium.</p>
]]></content:encoded>
			<wfw:commentRss>http://saucelabs.com/blog/index.php/2010/06/setting-up-cucumber-webrat-selenium/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A bit of sugar and parallelism for Rails and RSpec</title>
		<link>http://saucelabs.com/blog/index.php/2010/03/a-bit-of-sugar-and-parallelism-for-rails-and-rspec/</link>
		<comments>http://saucelabs.com/blog/index.php/2010/03/a-bit-of-sugar-and-parallelism-for-rails-and-rspec/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 00:14:05 +0000</pubDate>
		<dc:creator>The Sauce Labs Team</dc:creator>
				<category><![CDATA[Selenium Knowledge]]></category>
		<category><![CDATA[parallel testing]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[spec test]]></category>

		<guid isPermaLink="false">http://saucelabs.com/blog/?p=393</guid>
		<description><![CDATA[Even though we focus very heavily on full-stack acceptance testing for the rails world, we know other forms of automated tests are critical as well. Our rails developers here make pretty heavy use of RSpec unit tests, and it&#8217;s nice to understand how to run those in parallel as well. If you&#8217;re looking at how [...]]]></description>
			<content:encoded><![CDATA[<p>Even though we focus very heavily on full-stack acceptance testing for the rails world, we know other forms of automated tests are critical as well. Our rails developers here make pretty heavy use of RSpec unit tests, and it&#8217;s nice to understand how to run those in parallel as well.</p>
<p>If you&#8217;re looking at how to setup a rails and selenium testing environment, check out <a href="http://saucelabs.com/blog/index.php/2010/02/running-selenium-tests-for-rails">our last post</a>.</p>
<h2>Parallelize the specs</h2>
<p>We&#8217;ll use the excellent <a href="http://github.com/grosser/parallel_specs">parallel_specs</a> to beat a bit of parallelism into our specs. It prepares a separate database for each test environment, groups the specs to divide amongst processes, and then starts up a rails environment with a separate database for each group of processes.</p>
<p>I&#8217;ll paraphrase the installation instructions for convenience.</p>
<p>Install the required plug-in/gem:</p>
<pre class="brush:bash">sudo gem install parallel
script/plugin install git://github.com/grosser/parallel_specs.git</pre>
<p>Here&#8217;s the semi-ingenious point &#8211; yaml can interpret ERB, so we can pass in an environment variable to the database.yml specifying at launch which database we want it to connect to.</p>
<p>Open config/database.yml and add the following:</p>
<pre class="brush:yaml">test:
  adapter: sqlite3
  database: db/xxx_test&lt;% ENV['TEST_ENV_NUMBER'] %&gt;.sqlite3
  pool: 5
  timeout: 5000</pre>
<p>(You can of course replace xxx_ with your project name)<br />
So for example, to have our tests run against the xxx_test2 database, we would use:</p>
<pre class="brush:bash">export TEST_ENV_NUMBER=2; rake db:test:prepare</pre>
<p>But it doesn&#8217;t make much sense to invoke it manually. That&#8217;s what plug-ins are for! Let&#8217;s go head and create/migrate a few test databases:</p>
<pre class="brush:bash">export TEST_ENV_NUMBER=0; rake db:test:create; rake db:test:migrate;
export TEST_ENV_NUMBER=1; rake db:test:create; rake db:test:migrate;
export TEST_ENV_NUMBER=2; rake db:test:create; rake db:test:migrate;</pre>
<p>Great, now you&#8217;re able to run your non-Selenium tests in parallel!</p>
<h2>But what about Selenium tests?</h2>
<p>Stay tuned for our article on Sauce Labs&#8217; SpecStorm plugin, that allows you to run your Selenium tests in <em>true</em> parallel fashion with Selenium Grid or our very own <a href="http://saucelabs.com/products/sauce-ondemand">Sauce OnDemand</a> service.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsaucelabs.com%2Fblog%2Findex.php%2F2010%2F03%2Fa-bit-of-sugar-and-parallelism-for-rails-and-rspec%2F&amp;title=A%20bit%20of%20sugar%20and%20parallelism%20for%20Rails%20and%20RSpec" id="wpa2a_8"><img src="http://saucelabs.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://saucelabs.com/blog/index.php/2010/03/a-bit-of-sugar-and-parallelism-for-rails-and-rspec/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Running Selenium RSpec tests for Rails 2.3.5</title>
		<link>http://saucelabs.com/blog/index.php/2010/02/running-selenium-tests-for-rails/</link>
		<comments>http://saucelabs.com/blog/index.php/2010/02/running-selenium-tests-for-rails/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 20:03:24 +0000</pubDate>
		<dc:creator>The Sauce Labs Team</dc:creator>
				<category><![CDATA[Selenium Knowledge]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[rspec-rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://saucelabs.com/blog/?p=349</guid>
		<description><![CDATA[This article will get you setup with the bare-minimum environment to run Selenium tests with RSpec, for automated, full-stack testing of Rails apps. Once that&#8217;s done, we&#8217;ll work on polishing it for a nicer experience. In this post you find amalgamations of mostly outdated articles from around the internet updated to work with a modern [...]]]></description>
			<content:encoded><![CDATA[<p>This article will get you setup with the bare-minimum environment to run Selenium tests with RSpec, for automated, full-stack testing of Rails apps. Once that&#8217;s done, we&#8217;ll work on polishing it for a nicer experience. In this post you find amalgamations of mostly outdated articles from around the internet updated to work with a modern rails system.</p>
<p>It&#8217;s written on a clean environment courtesy of <a href="http://rvm.beginrescueend.com/">rvm</a>, so you may have some of the gems already setup.</p>
<h3>A new Rails app, RSpec, and rspec-rails</h3>
<p>First off, we&#8217;ll start with a new rails project:</p>
<pre class="brush:bash">gem install rails --no-ri --no-rdoc
rails rspec_saucerc
gem install rspec
gem install rspec-rails</pre>
<p>Edit config/environment.rb and add:</p>
<pre class="brush:ruby">  config.gem "rspec", :lib =&gt; false, :version =&gt; "&gt;= 1.2.9"
  config.gem "rspec-rails", :lib =&gt; false, :version =&gt; "&gt;= 1.2.9"</pre>
<p>This sets up all the required files for RSpec to get off the ground, but we need to integrate it into Rails:</p>
<pre class="brush:bash">script/generate rspec</pre>
<p>That will add the rake tasks, create the appropriate directories, and basic files. Now let&#8217;s get Selenium up and running!</p>
<h3>Selenium</h3>
<p>We&#8217;ll need to create a separate selenium database. in config/database.yml, let&#8217;s add:</p>
<pre class="brush:yaml">selenium:
  adapter: sqlite3
  database: db/selenium.sqlite3
  encoding: utf8
  timeout: 5000</pre>
<p>To get Selenium running under our RSpec stories, we&#8217;ll need the Selenium gem (note the capital &#8220;S&#8221; — it&#8217;s case-sensitive). Let&#8217;s also make sure we have the sqlite3 gem installed, and then prepare an appropriate environment for our selenium tests:</p>
<pre class="brush:bash">gem install Selenium
gem install sqlite3-ruby
cp config/environments/test.rb config/environments/selenium.rb</pre>
<p>Open config/environments/selenium.rb and remove the last line that reads:</p>
<pre class="brush:ruby">config.gem 'rspec-rails', :version =&gt; '&gt;= 1.3.2', :lib =&gt; false unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))</pre>
<h3>Sauce RC and Selenium RC</h3>
<p>Sauce RC will broker all communication between rails and any browsers you might be driving. Get it from our <a href="http://saucelabs.com/products/downloads">downloads</a> page for Windows or Mac, or use <a href="http://seleniumhq.org/projects/remote-control/">Selenium RC</a> for Linux, and start it up so we can run our tests.</p>
<h3>Testables</h3>
<p>We&#8217;ll need some fodder to test. Use the RSpec generator, then create and migrate the database:</p>
<pre class="brush:bash">script/generate rspec_scaffold person name:string age:string language:string
rake RAILS_ENV=selenium db:create
rake RAILS_ENV=selenium db:migrate</pre>
<h3>Startup our test server</h3>
<p>Rails tests do not normally bind to a webserver, so there is no way for Selenium to access the frontend. As a temporary workaround, we&#8217;ll manually invoke a Rails server using the selenium environment:</p>
<pre class="brush:bash">script/server -e selenium</pre>
<h3>Our spec helper</h3>
<p>We will be using the Selenium gem, so let&#8217;s add it to the spec helper:</p>
<pre class="brush:ruby">gem "selenium-client"
require "selenium/client"
require "selenium/rspec/spec_helper"</pre>
<h3>Example story</h3>
<p>We&#8217;ll gloss over which types of tests should include selenium front-end testing for now, and just say it belongs in integration tests. Let&#8217;s run an example story that will fail the first time through, and we&#8217;ll then fix it.</p>
<p>Put the following in spec/integration/people_spec.rb:</p>
<pre class="brush:ruby">require 'spec_helper'
describe "People" do
  before(:all) do
    @verification_errors = []

    @browser = Selenium::Client::Driver.new(
      :host =&gt; "localhost",
      :port =&gt; 4444,
      :browser =&gt; "*firefox"
      :url =&gt; "http://localhost:3000",
      :timeout_in_second =&gt; 90)

    @browser.start
  end

  before(:each) do
    @browser.start_new_browser_session
  end

  append_after(:each) do
    @browser.close_current_browser_session
    @verification_errors.should == []
  end

  it "should create a new Person with valid input" do
    @browser.open "/people"
    @browser.click "link=New person"
    @browser.wait_for_page_to_load "2000"
    @browser.type "person_name", "Jason Huggins"
    @browser.type "person_age", "26"
    @browser.type "person_language", "Albanian"
    @browser.click "person_submit"
    @browser.wait_for_page_to_load "30000"
    @browser.is_alert_present.should be_true
  end
end</pre>
<p>Let&#8217;s try it out:</p>
<pre class="brush:bash">rake spec:integration
F
1) 'People should create a new Person with valid input' FAILED
expected false to be true
./spec/integration/people_spec.rb:22:

Finished in 7.443904 seconds

1 example, 1 failure</pre>
<p>It&#8217;s failing as we expected it to (there shouldn&#8217;t be a javascript alert on submit). Let&#8217;s change the last line:</p>
<pre class="brush:ruby">    @browser.is_alert_present.should be_false</pre>
<p>&#8230; and try our test again:</p>
<pre class="brush:bash">rake spec:integration
.

Finished in 7.079062 seconds

1 example, 0 failures</pre>
<p>Looks good! We finally have a working rails project with rspec runners and Selenium.</p>
<h3>Weaknesses</h3>
<p>Although we&#8217;ve got Rails, RSpec, and Selenium all working together, the relationship is not harmonious.</p>
<p>Automated tests in rails are not meant to serve the outside world, and as such they don&#8217;t bind to a webserver/port. Tests are run within the same process, which makes them quite fast, but prevents us from using browser-based frontend tools such as Selenium. To get around that, we manually fired up a rails server instance with the selenium environment, but this is messy for a number of reasons:</p>
<ul>
<li>We have to manually start/stop the test server that selenium wants to access</li>
<li>We have to manually create the selenium environment&#8217;s database</li>
<li>We have to manually migrate the selenium environment each time there&#8217;s a schema change</li>
<li>Worse, we have to manually reset the database after each run</li>
<li>Running Selenium tests in serial is <em>slow</em></li>
</ul>
<p>We‘ve developed a plugin to automate some of these issues, called <a href="http://github.com/sgrove/spec_storm">SpecStorm</a>. We&#8217;ll go over installing it to get the most out of your tests (including running them in parallel) in the next post.</p>
<p>Notes:</p>
<p>Selenium matchers are case-sensitive: @browser.click &#8220;link=New Person&#8221; won&#8217;t match a link with &#8220;New person&#8221;</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsaucelabs.com%2Fblog%2Findex.php%2F2010%2F02%2Frunning-selenium-tests-for-rails%2F&amp;title=Running%20Selenium%20RSpec%20tests%20for%20Rails%202.3.5" id="wpa2a_10"><img src="http://saucelabs.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://saucelabs.com/blog/index.php/2010/02/running-selenium-tests-for-rails/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

