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
|
||||
driver.reset!
|
||||
@touched = false
|
||||
@scopes = [nil]
|
||||
end
|
||||
@server&.wait_for_pending_requests
|
||||
raise_server_error!
|
||||
|
|
|
@ -95,6 +95,19 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|||
expect(@session.windows.size).to eq 1
|
||||
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
|
||||
let!(:orig_reuse_server) { Capybara.reuse_server }
|
||||
|
||||
|
|
|
@ -177,6 +177,22 @@ class TestApp < Sinatra::Base
|
|||
HTML
|
||||
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
|
||||
<<-HTML
|
||||
<!DOCTYPE html>
|
||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe 'capybara/rspec' do
|
|||
expect(self.class.ancestors).to include Capybara::RSpecMatcherProxies
|
||||
end
|
||||
|
||||
context 'resetting session' do
|
||||
context 'resetting session', order: :defined do
|
||||
it 'sets a cookie in one example...' do
|
||||
visit('/set_cookie')
|
||||
expect(page.body).to include('Cookie set to test_cookie')
|
||||
|
@ -27,7 +27,7 @@ RSpec.describe 'capybara/rspec' do
|
|||
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
|
||||
Capybara.current_driver = :selenium
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue