我在 rspec 中有一个硒套件。
如何运行多个案例并保持浏览器打开并在它们之间登录?
我在 selenium IDE 中有一个测试套件,它由大约 20 个单元案例组成。
我已将单个测试用例和测试套件文件本身都导出到 ruby/rspec
我可以运行单独的测试并且它们通过了,例如
rspec spec/2day/units/set_QA_district_name_spec.rb
但是,当我尝试使用任何一个运行转换后的套件时
rake spec
或者
rspec spec/2day/complete_district_suite_spec.rb
它通过为每个测试启动(然后关闭)应用程序来逐个运行每个规范。
如何运行该套件并让浏览器“保持”并从一个测试到另一个测试登录,而不是为每个运行的单元测试打开然后关闭浏览器窗口。
我必须在我创建的独立目录中运行这些测试,因为它们必须与其他应用程序测试区域分开,换句话说,我必须避免使用 rails 本身。
我已经在这些文件的根目录中设置了以下 Gemfile / spec_helper / Rake 文件,如下所示:
宝石文件:
gem 'rspec'
gem 'selenium-webdriver'
spec_runner.rb:
require "selenium-webdriver"
require 'rspec'
耙文件
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
complete_district_suite.rb 的内容是:
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")