teamcapybara/capybara · error · Capybara::ModalNotFound
Unable to find modal dialog#{" with #{text}" if text}
Error message
Unable to find modal dialog#{" with #{text}" if text} What it means
Error "Unable to find modal dialog#{" with #{text}" if text}" thrown in teamcapybara/capybara.
Source
Thrown at lib/capybara/selenium/driver.rb:417
# Selenium has its own built in wait (2 seconds)for a modal to show up, so this wait is really the minimum time
# Actual wait time may be longer than specified
wait = Selenium::WebDriver::Wait.new(
timeout: options.fetch(:wait, session_options.default_max_wait_time) || 0,
ignore: modal_error
)
begin
wait.until do
alert = @browser.switch_to.alert
regexp = text.is_a?(Regexp) ? text : Regexp.new(Regexp.escape(text.to_s))
matched = alert.text.match?(regexp)
unless matched
raise Capybara::ModalNotFound, "Unable to find modal dialog with #{text} - found '#{alert.text}' instead."
end
alert
end
rescue *find_modal_errors
raise Capybara::ModalNotFound, "Unable to find modal dialog#{" with #{text}" if text}"
end
end
def find_modal_errors
@find_modal_errors ||= [Selenium::WebDriver::Error::TimeoutError]
end
def silenced_unknown_error_message?(msg)
silenced_unknown_error_messages.any? { |regex| msg.match? regex }
end
def silenced_unknown_error_messages
[/Error communicating with the remote browser/]
end
def unwrap_script_result(arg)
case arg
when ArrayView on GitHub (pinned to 15b5fdb76e)
When it happens
Trigger: Thrown at lib/capybara/selenium/driver.rb:417 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of teamcapybara/capybara@15b5fdb76e (2026-08-21).
Data as JSON: /api/errors/1c0e6439c0bdfc8b.
Report an issue: GitHub.