1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Test session resetting scopes

This commit is contained in:
Henry Blyth 2022-06-08 12:12:57 +01:00
parent 6a34f8d6dd
commit d1aad55ff3
2 changed files with 29 additions and 0 deletions

View file

@ -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 }

View file

@ -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>