我有单独的测试而不是运行正常
rspec test_name_spec.rb
每一个都包含@driver = Selenium::WebDriver
我需要运行它们并保持登录状态,使用从测试到测试的相同窗口。
我设置了一个套件,但是当我使用下面的代码将@driver=
分配移动到 a时before(:all)
,我收到一个错误,因为@driver
它是 null:
describe "district" do
before(:all) do
@driver = Selenium::WebDriver.for :firefox
end
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/login_as_admin_spec.rb")
end
错误:
1) SetQADistrictName test_set_q_a_district_name
Failure/Error: @driver.manage.timeouts.implicit_wait = 30
NoMethodError:
undefined method `manage' for nil:NilClass
set_QA_district_name 的内容:
require_relative "../../../spec_helper"
include RSpec::Expectations
describe "SetQADistrictName" do
before(:each) do
@driver = Selenium::WebDriver.for :firefox
@base_url = "http://dmstaffing-stage.herokuapp.com/"
@accept_next_alert = true
@driver.manage.timeouts.implicit_wait = 30
@verification_errors = []
end
after(:each) do
#@driver.quit
@verification_errors.should == []
end
it "test_set_q_a_district_name" do
QA_run_number = "056"
end
def element_present?(how, what)
@driver.find_element(how, what)
true
rescue Selenium::WebDriver::Error::NoSuchElementError
false
end
def verify(&blk)
yield
rescue ExpectationNotMetError => ex
@verification_errors << ex
end
def close_alert_and_get_its_text(how, what)
alert = @driver.switch_to().alert()
if (@accept_next_alert) then
alert.accept()
else
alert.dismiss()
end
alert.text
ensure
@accept_next_alert = true
end
end