mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Ensure modal methods receive a block when using headless chrome
This commit is contained in:
parent
8ee039b7e5
commit
ec4d32f7d2
2 changed files with 11 additions and 3 deletions
|
@ -245,8 +245,9 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
|
||||
def accept_modal(_type, options={})
|
||||
if headless_chrome?
|
||||
raise ArgumentError, "Block that triggers the system modal is missing" unless block_given?
|
||||
insert_modal_handlers(true, options[:with], options[:text])
|
||||
yield if block_given?
|
||||
yield
|
||||
find_headless_modal(options)
|
||||
else
|
||||
yield if block_given?
|
||||
|
@ -260,8 +261,9 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
|
||||
def dismiss_modal(_type, options={})
|
||||
if headless_chrome?
|
||||
raise ArgumentError, "Block that triggers the system modal is missing" unless block_given?
|
||||
insert_modal_handlers(false, options[:with], options[:text])
|
||||
yield if block_given?
|
||||
yield
|
||||
find_headless_modal(options)
|
||||
else
|
||||
yield if block_given?
|
||||
|
|
|
@ -57,12 +57,18 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
|
|||
|
||||
describe "#accept_alert" do
|
||||
it "supports a blockless mode" do
|
||||
skip "Headless Chrome doesn't support blockless modal methods" if @session.driver.send(:headless_chrome?)
|
||||
@session.visit('/with_js')
|
||||
skip "Headless Chrome doesn't support blockless modal methods" if @session.driver.send(:headless_chrome?)
|
||||
@session.click_link('Open alert')
|
||||
@session.accept_alert
|
||||
expect{@session.driver.browser.switch_to.alert}.to raise_error(Selenium::WebDriver::Error::NoAlertPresentError)
|
||||
end
|
||||
|
||||
it "raises if block is missing" do
|
||||
@session.visit('/with_js')
|
||||
skip "Only Headless Chrome requires the block due to system modal JS injection" unless @session.driver.send(:headless_chrome?)
|
||||
expect { @session.accept_alert }.to raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
context "#fill_in with { :clear => :backspace } fill_option", requires: [:js] do
|
||||
|
|
Loading…
Reference in a new issue