diff --git a/lib/capybara/selenium/driver.rb b/lib/capybara/selenium/driver.rb index 732fc728..acad781c 100644 --- a/lib/capybara/selenium/driver.rb +++ b/lib/capybara/selenium/driver.rb @@ -51,10 +51,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base end def refresh - accept_modal(nil, wait: 0.1) do - browser.navigate.refresh - end - rescue Capybara::ModalNotFound + browser.navigate.refresh end def go_back diff --git a/lib/capybara/spec/session/refresh_spec.rb b/lib/capybara/spec/session/refresh_spec.rb index 75f1fd73..b1ca1680 100644 --- a/lib/capybara/spec/session/refresh_spec.rb +++ b/lib/capybara/spec/session/refresh_spec.rb @@ -17,6 +17,7 @@ Capybara::SpecHelper.spec '#refresh' do end it "it reposts" do + skip "Firefox insists on prompting without providing a way to suppress" if marionette?(@session) @session.visit('/form') @session.select('Sweden', from: 'form_region') @session.click_button('awesome') diff --git a/lib/capybara/spec/spec_helper.rb b/lib/capybara/spec/spec_helper.rb index 721ad97e..4f734b7f 100644 --- a/lib/capybara/spec/spec_helper.rb +++ b/lib/capybara/spec/spec_helper.rb @@ -106,7 +106,7 @@ module Capybara end def marionette?(session) - session.driver.respond_to?(:marionette?, true) && session.driver.send(:marionette?) + session.respond_to?(:driver) && session.driver.respond_to?(:marionette?, true) && session.driver.send(:marionette?) end end end diff --git a/spec/selenium_spec_marionette.rb b/spec/selenium_spec_marionette.rb index e07104ec..7bd5b1ae 100644 --- a/spec/selenium_spec_marionette.rb +++ b/spec/selenium_spec_marionette.rb @@ -123,5 +123,25 @@ RSpec.describe Capybara::Selenium::Driver do end end end + + context "#refresh" do + def extract_results(session) + expect(session).to have_xpath("//pre[@id='results']") + YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip + end + + it "can repost by accepting confirm" do + @session = TestSessions::SeleniumMarionette + @session.visit('/form') + @session.select('Sweden', from: 'form_region') + @session.click_button('awesome') + expect { + @session.accept_confirm(wait: 0.1) do + @session.refresh + sleep 2 + end + }.to change{ extract_results(@session)['post_count'] }.by(1) + end + end end