title: selenium suite in ruby/rspec - how to run multiple cases and stay logged in?
body: <p>I have a selenium suite in rspec.  </p>
  
  <p>How can I run multiple cases and keep the browser open and logged in between them?</p>
  
  <p>I have a test suite in the selenium IDE that is comprised of about 20 unit cases.</p>
  
  <p>I've exported both the individual test cases and the test suite file itself to ruby/rspec</p>
  
  <p>I can run individual tests and they pass, e.g.</p>
  
  <pre><code>rspec spec/2day/units/set_QA_district_name_spec.rb
  </code></pre>
  
  <p>However when I tried to run the converted suite with either</p>
  
  <pre><code>rake spec
  </code></pre>
  
  <p>or</p>
  
  <pre><code>rspec spec/2day/complete_district_suite_spec.rb 
  </code></pre>
  
  <p>it runs each spec one-by-one by bringing up (and then closing) the application for each test.</p>
  
  <p>How can I run the suite and have the browser 'stay' up and logged in from test to test and not be opening and then closing down the browser window for each unit test that runs.</p>
  
  <p>I have to run these tests in the standalone directory that I've created as they have to be kept separate from the rest of the applications test areas, in other words I have to avoid any use of rails itself.</p>
  
  <p>I have set up the following Gemfile / spec_helper / Rake files in the root directory for these files as follows:</p>
  
  <h2>Gemfile:</h2>
  
  <pre><code>gem 'rspec'
  gem 'selenium-webdriver'
  </code></pre>
  
  <h2>spec_runner.rb:</h2>
  
  <pre><code>require "selenium-webdriver"
  require 'rspec'
  </code></pre>
  
  <h2>Rakefile</h2>
  
  <pre><code>require 'rspec'
  require 'rspec/core/rake_task'
  desc "Run all examples"
  RSpec::Core::RakeTask.new(:spec) do |t|
    t.ruby_opts = %w[-w]
    t.rspec_opts = %w[--color]
  end
  </code></pre>
  
  <p>The contents of complete_district_suite.rb are:</p>
  
  <pre><code>ENV['RSPEC_COLOR'] = 'true'
  
  require File.join(File.dirname(__FILE__),  "units/set_QA_district_name_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/set_file_uploads_source_location_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/district_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/select_district_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/upload_service_types_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/upload_services_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/upload_grades_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/upload_schools_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/upload_classrooms_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/upload_students_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/upload_ieps_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/upload_travel_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/manual_add_student_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/generate_basic_schedule_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/wait_for_dss_to_finish_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/view_schedules_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/visit_first_schedule_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/monday_1pm_new_appt_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/tuesday_2pm_new_5_students_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/wednesday_9am_5pm_new_1_student_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/thursday_9am_10am_new_1_manual_add_student_spec.rb")
  require File.join(File.dirname(__FILE__),  "units/friday_10am_11am_new_5_students_spec.rb")
  </code></pre>