{"record":{"id":"1c0e6439c0bdfc8b","repo":"teamcapybara/capybara","slug":"unable-to-find-modal-dialog-with-text-if-te","errorCode":null,"errorMessage":"Unable to find modal dialog#{\" with #{text}\" if text}","messagePattern":"Unable to find modal dialog#(.+?)\" if text\\}","errorType":"exception","errorClass":"Capybara::ModalNotFound","httpStatus":null,"severity":"error","filePath":"lib/capybara/selenium/driver.rb","lineNumber":417,"sourceCode":"    # Selenium has its own built in wait (2 seconds)for a modal to show up, so this wait is really the minimum time\n    # Actual wait time may be longer than specified\n    wait = Selenium::WebDriver::Wait.new(\n      timeout: options.fetch(:wait, session_options.default_max_wait_time) || 0,\n      ignore: modal_error\n    )\n    begin\n      wait.until do\n        alert = @browser.switch_to.alert\n        regexp = text.is_a?(Regexp) ? text : Regexp.new(Regexp.escape(text.to_s))\n        matched = alert.text.match?(regexp)\n        unless matched\n          raise Capybara::ModalNotFound, \"Unable to find modal dialog with #{text} - found '#{alert.text}' instead.\"\n        end\n\n        alert\n      end\n    rescue *find_modal_errors\n      raise Capybara::ModalNotFound, \"Unable to find modal dialog#{\" with #{text}\" if text}\"\n    end\n  end\n\n  def find_modal_errors\n    @find_modal_errors ||= [Selenium::WebDriver::Error::TimeoutError]\n  end\n\n  def silenced_unknown_error_message?(msg)\n    silenced_unknown_error_messages.any? { |regex| msg.match? regex }\n  end\n\n  def silenced_unknown_error_messages\n    [/Error communicating with the remote browser/]\n  end\n\n  def unwrap_script_result(arg)\n    case arg\n    when Array","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/teamcapybara/capybara/blob/15b5fdb76e972e9623d5af2123ed3755594f9732/lib/capybara/selenium/driver.rb#L399-L435","documentation":"Error \"Unable to find modal dialog#{\" with #{text}\" if text}\" thrown in teamcapybara/capybara.","triggerScenarios":"Thrown at lib/capybara/selenium/driver.rb:417 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"15b5fdb76e972e9623d5af2123ed3755594f9732","analyzedAt":"2026-08-21T16:53:45.588Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}