Merge pull request #1986 from teamcapybara/reset_windows
Driver reset! should close all but 1 window
This commit is contained in:
commit
590793d004
|
@ -108,6 +108,8 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
# Use instance variable directly so we avoid starting the browser just to reset the session
|
||||
return unless @browser
|
||||
|
||||
window_handles.reject { |handle| handle == current_window_handle }.each { |win| close_window(win) }
|
||||
|
||||
navigated = false
|
||||
start_time = Capybara::Helpers.monotonic_time
|
||||
begin
|
||||
|
|
|
@ -63,6 +63,24 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|||
expect(@session.current_path).to eq("/")
|
||||
end
|
||||
|
||||
it "closes extra windows", requires: [:windows] do
|
||||
@session.visit('/with_html')
|
||||
@session.open_new_window
|
||||
@session.open_new_window
|
||||
expect(@session.windows.size).to eq 3
|
||||
@session.reset_session!
|
||||
expect(@session.windows.size).to eq 1
|
||||
end
|
||||
|
||||
it "closes extra windows when not on the first window", requires: [:windows] do
|
||||
@session.visit('/with_html')
|
||||
@session.switch_to_window(@session.open_new_window)
|
||||
@session.open_new_window
|
||||
expect(@session.windows.size).to eq 3
|
||||
@session.reset_session!
|
||||
expect(@session.windows.size).to eq 1
|
||||
end
|
||||
|
||||
context "When reuse_server == false" do
|
||||
before do
|
||||
@reuse_server = Capybara.reuse_server
|
||||
|
|
Loading…
Reference in New Issue