mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge pull request #2563 from henrahmagix/patch-2
Reset @scopes when session is reset
This commit is contained in:
commit
6cba8b4b5a
4 changed files with 32 additions and 2 deletions
|
@ -130,6 +130,7 @@ module Capybara
|
||||||
if @touched
|
if @touched
|
||||||
driver.reset!
|
driver.reset!
|
||||||
@touched = false
|
@touched = false
|
||||||
|
@scopes = [nil]
|
||||||
end
|
end
|
||||||
@server&.wait_for_pending_requests
|
@server&.wait_for_pending_requests
|
||||||
raise_server_error!
|
raise_server_error!
|
||||||
|
|
|
@ -95,6 +95,19 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
||||||
expect(@session.windows.size).to eq 1
|
expect(@session.windows.size).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not block opening a new window after a frame was switched to and not switched back', requires: [:windows] do
|
||||||
|
@session.visit('/with_iframe?id=test_iframe&url=/')
|
||||||
|
@session.switch_to_frame(@session.find(:frame, 'test_iframe'))
|
||||||
|
within_window_test = lambda do
|
||||||
|
@session.within_window(@session.open_new_window) do
|
||||||
|
@session.visit('/')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expect(&within_window_test).to raise_error(Capybara::ScopeError)
|
||||||
|
@session.reset_session!
|
||||||
|
expect(&within_window_test).not_to raise_error
|
||||||
|
end
|
||||||
|
|
||||||
context 'When reuse_server == false' do
|
context 'When reuse_server == false' do
|
||||||
let!(:orig_reuse_server) { Capybara.reuse_server }
|
let!(:orig_reuse_server) { Capybara.reuse_server }
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,22 @@ class TestApp < Sinatra::Base
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get '/with_iframe' do
|
||||||
|
<<-HTML
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
||||||
|
<title>Test with Iframe</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<iframe src="#{params[:url]}" id="#{params[:id]}"></iframe>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
|
||||||
get '/base/with_base' do
|
get '/base/with_base' do
|
||||||
<<-HTML
|
<<-HTML
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe 'capybara/rspec' do
|
||||||
expect(self.class.ancestors).to include Capybara::RSpecMatcherProxies
|
expect(self.class.ancestors).to include Capybara::RSpecMatcherProxies
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'resetting session' do
|
context 'resetting session', order: :defined do
|
||||||
it 'sets a cookie in one example...' do
|
it 'sets a cookie in one example...' do
|
||||||
visit('/set_cookie')
|
visit('/set_cookie')
|
||||||
expect(page.body).to include('Cookie set to test_cookie')
|
expect(page.body).to include('Cookie set to test_cookie')
|
||||||
|
@ -27,7 +27,7 @@ RSpec.describe 'capybara/rspec' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'setting the current driver' do
|
context 'setting the current driver', order: :defined do
|
||||||
it 'sets the current driver in one example...' do
|
it 'sets the current driver in one example...' do
|
||||||
Capybara.current_driver = :selenium
|
Capybara.current_driver = :selenium
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue