selenium suite in ruby/rspec - how to run multiple cases and stay logged in? -
i have selenium suite in rspec.
how can run multiple cases , keep browser open , logged in between them?
i have test suite in selenium ide comprised of 20 unit cases.
i've exported both individual test cases , test suite file ruby/rspec
i can run individual tests , pass, e.g.
rspec spec/2day/units/set_qa_district_name_spec.rb
however when tried run converted suite either
rake spec
or
rspec spec/2day/complete_district_suite_spec.rb
it runs each spec one-by-one bringing (and closing) application each test.
how can run suite , have browser 'stay' , logged in test test , not opening , closing down browser window each unit test runs.
i have run these tests in standalone directory i've created have kept separate rest of applications test areas, in other words have avoid use of rails itself.
i have set following gemfile / spec_helper / rake files in root directory these files follows:
gemfile:
gem 'rspec' gem 'selenium-webdriver'
spec_runner.rb:
require "selenium-webdriver" require 'rspec'
rakefile
require 'rspec' require 'rspec/core/rake_task' desc "run examples" rspec::core::raketask.new(:spec) |t| t.ruby_opts = %w[-w] t.rspec_opts = %w[--color] end
the contents of complete_district_suite.rb are:
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")
i think looking before(:all)
describe "search page" before(:all) @browser = watir::browser.new end "should find contacts" ... end after(:all) @browser.kill! rescue nil end end
more info here
suggestion
also include spec files in 1 line :-
dir[file.join(file.dirname(__file__), 'units') + "/*_spec.rb"].each { |file| require file }
Comments
Post a Comment