{"record":{"id":"2746badcd24b3bc4","repo":"teamcapybara/capybara","slug":"unable-to-find-query-applied-description","errorCode":null,"errorMessage":"Unable to find #{query.applied_description}","messagePattern":"Unable to find #(.+?)","errorType":"exception","errorClass":"Capybara::ElementNotFound","httpStatus":null,"severity":"error","filePath":"lib/capybara/node/finders.rb","lineNumber":312,"sourceCode":"        options = { minimum: 1 }.merge(options) unless options_include_minimum?(options)\n        all(*args, **options, &optional_filter_block).first\n      end\n\n    private\n\n      def synced_resolve(query)\n        synchronize(query.wait) do\n          if prefer_exact?(query)\n            result = query.resolve_for(self, true)\n            result = query.resolve_for(self, false) if result.empty? && query.supports_exact? && !query.exact?\n          else\n            result = query.resolve_for(self)\n          end\n\n          if ambiguous?(query, result)\n            raise Capybara::Ambiguous, \"Ambiguous match, found #{result.size} elements matching #{query.applied_description}\"\n          end\n          raise Capybara::ElementNotFound, \"Unable to find #{query.applied_description}\" if result.empty?\n\n          result.first\n        end.tap(&:allow_reload!)\n      end\n\n      def ambiguous?(query, result)\n        %i[one smart].include?(query.match) && (result.size > 1)\n      end\n\n      def prefer_exact?(query)\n        %i[smart prefer_exact].include?(query.match)\n      end\n\n      def options_include_minimum?(opts)\n        %i[count minimum between].any? { |key| opts.key?(key) }\n      end\n\n      def parent","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/teamcapybara/capybara/blob/15b5fdb76e972e9623d5af2123ed3755594f9732/lib/capybara/node/finders.rb#L294-L330","documentation":"The canonical Capybara::ElementNotFound from Finders#find (synced_resolve): after retrying for the query's wait time, the selector plus applied filters (:text, :visible, etc.) resolved to zero elements. The message embeds query.applied_description, e.g. \"Unable to find visible css 'a' with text 'Continue'\". find is an assertion-grade API: it blocks and retries, then fails hard instead of returning nil.","triggerScenarios":"find('#notice') before an AJAX action has rendered it; find('a', text: 'Sign out') when the text differs by whitespace/case; find('.item', visible: true) when the element exists but is hidden; a typo'd locator find('#sucess'); find on a page that hasn't finished navigating.","commonSituations":"Race between test step and async rendering when default_max_wait_time is short (common on slow CI), elements behind tabs/accordions that are display:none until opened, React/Vue re-rendering replacing a node mid-find, iframe scope mistakes (find inside page when the element is in a frame).","solutions":["Raise the wait: find('#notice', wait: 10) or Capybara.default_max_wait_time = 5","Copy the exact locator from the failure message and check it against current DOM (save_and_open_page or browser devtools)","Drop or adjust mismatched filters: visible: false for hidden nodes, exact_text: false for partial text","Ensure the element is genuinely exposed first (click the tab, scroll, switch frame via within_frame)"],"exampleFix":"# before\nfind('#status-message').text\n\n# after\nfind('#status-message', wait: 10).text\n# or assert with waiting semantics first\nexpect(page).to have_css('#status-message', wait: 10)\nfind('#status-message').text","handlingStrategy":"retry","validationCode":"if page.has_selector?('#notice', wait: 10)\n  find('#notice').text\nelse\n  save_and_open_page # debug the actual DOM\nend","typeGuard":null,"tryCatchPattern":"begin\n  find('#notice', wait: 10)\nrescue Capybara::ElementNotFound => e\n  raise unless page.has_selector?('.fallback-notice', wait: 2)\n  find('.fallback-notice')\nend","preventionTips":["Use waiting find/RSpec matchers instead of driver-native queries","Give find an explicit wait: for elements rendered by slow AJAX","Assert a stable container exists before finding children inside it"],"tags":["capybara","element-not-found","find","waiting","selector"],"backgroundTag":"element-not-found","analyzedSha":"15b5fdb76e972e9623d5af2123ed3755594f9732","analyzedAt":"2026-08-21T16:53:45.588Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}