mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
allow for blockless modal methods in selenium
This commit is contained in:
parent
b2b4d0996f
commit
d9dff6a80f
2 changed files with 12 additions and 3 deletions
|
@ -205,7 +205,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
end
|
||||
|
||||
def accept_modal(type, options={}, &blk)
|
||||
yield
|
||||
yield if block_given?
|
||||
modal = find_modal(options)
|
||||
modal.send_keys options[:with] if options[:with]
|
||||
message = modal.text
|
||||
|
@ -214,7 +214,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
end
|
||||
|
||||
def dismiss_modal(type, options={}, &blk)
|
||||
yield
|
||||
yield if block_given?
|
||||
modal = find_modal(options)
|
||||
message = modal.text
|
||||
modal.dismiss
|
||||
|
|
|
@ -63,6 +63,16 @@ RSpec.describe Capybara::Session do
|
|||
expect($?.exitstatus).to be 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "#accept_alert", focus: true do
|
||||
it "supports a blockless mode" do
|
||||
@session.visit('/with_js')
|
||||
@session.click_link('Open alert')
|
||||
expect(@session.driver.browser.switch_to.alert).to be_kind_of Selenium::WebDriver::Alert
|
||||
@session.accept_alert
|
||||
expect{@session.driver.browser.switch_to.alert}.to raise_error("No alert is present")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -81,4 +91,3 @@ RSpec.describe Capybara::Selenium::Driver do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue