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

Workaround Firefox asking if sure to repost when calling refresh

This commit is contained in:
Thomas Walpole 2018-08-14 14:37:24 -07:00
parent 7fee32b214
commit 92a67feff2
4 changed files with 10 additions and 27 deletions

View file

@ -23,6 +23,15 @@ module Capybara::Selenium::Driver::MarionetteDriver
super super
end end
def refresh
# Accept any "will repost content" confirmation that occurs
accept_modal :confirm, wait: 0.1 do
super
end
rescue Capybara::ModalNotFound # rubocop:disable Lint/HandleExceptions
# No modal was opened - page has refreshed - ignore
end
private private
def build_node(native_node) def build_node(native_node)

View file

@ -64,8 +64,6 @@ Capybara::SpecHelper.run_specs TestSessions::RemoteFirefox, FIREFOX_REMOTE_DRIVE
pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session) pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session)
when /^Capybara::Session selenium node #double_click/ when /^Capybara::Session selenium node #double_click/
pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session) pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session)
when 'Capybara::Session selenium_firefox_remote #refresh it reposts'
skip 'Firefox insists on prompting without providing a way to suppress'
when 'Capybara::Session selenium_firefox_remote #accept_prompt should accept the prompt with a blank response when there is a default' when 'Capybara::Session selenium_firefox_remote #accept_prompt should accept the prompt with a blank response when there is a default'
pending "Geckodriver doesn't set a blank response currently" pending "Geckodriver doesn't set a blank response currently"
when 'Capybara::Session selenium_firefox_remote #attach_file with multipart form should fire change once for each set of files uploaded', when 'Capybara::Session selenium_firefox_remote #attach_file with multipart form should fire change once for each set of files uploaded',

View file

@ -27,7 +27,7 @@ TestSessions::SeleniumIE.current_window.resize_to(1600, 1200)
Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_skip: skipped_tests do |example| Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_skip: skipped_tests do |example|
case example.metadata[:full_description] case example.metadata[:full_description]
when /#refresh it reposts$/ when /#refresh it reposts$/
skip 'Firefox and Edge insist on prompting without providing a way to suppress' skip 'IE insists on prompting without providing a way to suppress'
when /#click_link can download a file$/ when /#click_link can download a file$/
skip 'Not sure how to configure IE for automatic downloading' skip 'Not sure how to configure IE for automatic downloading'
when /#fill_in with Date / when /#fill_in with Date /

View file

@ -54,8 +54,6 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumMarionette, 'selenium', cap
pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session) pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session)
when /^Capybara::Session selenium node #double_click/ when /^Capybara::Session selenium node #double_click/
pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session) pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session)
when 'Capybara::Session selenium #refresh it reposts'
skip 'Firefox insists on prompting without providing a way to suppress'
when 'Capybara::Session selenium #accept_prompt should accept the prompt with a blank response when there is a default' when 'Capybara::Session selenium #accept_prompt should accept the prompt with a blank response when there is a default'
pending "Geckodriver doesn't set a blank response currently" pending "Geckodriver doesn't set a blank response currently"
when 'Capybara::Session selenium #attach_file with multipart form should fire change once for each set of files uploaded' when 'Capybara::Session selenium #attach_file with multipart form should fire change once for each set of files uploaded'
@ -145,28 +143,6 @@ RSpec.describe Capybara::Selenium::Driver do
end end
end 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')
sleep 1
expect do
@session.accept_confirm(wait: 0.1) do
@session.refresh
sleep 2
end
sleep 1
end.to change { extract_results(@session)['post_count'] }.by(1)
end
end
end end
RSpec.describe Capybara::Selenium::Node do RSpec.describe Capybara::Selenium::Node do