1
0
Fork 0
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:
Thomas Walpole 2014-07-02 19:10:30 -07:00
parent b2b4d0996f
commit d9dff6a80f
2 changed files with 12 additions and 3 deletions

View file

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

View file

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