Method: Capybara::Session#accept_alert

Defined in:
lib/capybara/session.rb

#accept_alert(text, **options) { ... } ⇒ String #accept_alert(**options) { ... } ⇒ String

Execute the block, accepting a alert.

Expects a block whose actions will trigger the display modal to appear.

Examples:

accept_alert do
  click_link('link that triggers appearance of system modal')
end

Overloads:

  • #accept_alert(text, **options) { ... } ⇒ String

    Parameters:

    • text (String, Regexp)

      Text or regex to match against the text in the modal. If not provided any modal is matched.

    Options Hash (**options):

    • :wait (Numeric)

      Maximum time to wait for the modal to appear after executing the block. Defaults to default_max_wait_time.

    Yields:

    • Block whose actions will trigger the system modal

  • #accept_alert(**options) { ... } ⇒ String

    Options Hash (**options):

    • :wait (Numeric)

      Maximum time to wait for the modal to appear after executing the block. Defaults to default_max_wait_time.

    Yields:

    • Block whose actions will trigger the system modal

Returns:

  • (String)

    the message shown in the modal

Raises:



659
660
661
# File 'lib/capybara/session.rb', line 659

def accept_alert(text = nil, **options, &blk)
  accept_modal(:alert, text, options, &blk)
end