{"record":{"id":"940c80fd3d3d03eb","repo":"teamcapybara/capybara","slug":"find-does-not-support-count-options-count-opt","errorCode":null,"errorMessage":"'find' does not support count options (#{count_options}) ignoring. Called from: #{Capybara::Helpers.filter_backtrace(caller)}","messagePattern":"'find' does not support count options \\(#(.+?)\\) ignoring\\. Called from: #(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/capybara/node/finders.rb","lineNumber":55,"sourceCode":"      #   @option options [String, Regexp]  id           Only find elements with an id that matches the value passed\n      #   @option options [String, Array<String>, Regexp] class  Only find elements with matching class/classes.\n      #                                            * Absence of a class can be checked by prefixing the class name with `!`\n      #                                            * If you need to check for existence of a class name that starts with `!` then prefix with `!!`\n      #\n      #                                                class:['a', '!b', '!!!c'] # limit to elements with class 'a' and '!c' but not class 'b'\n      #\n      #   @option options [String, Regexp, Hash] style  Only find elements with matching style. String and Regexp will be checked against text of the elements `style` attribute, while a Hash will be compared against the elements full style\n      #   @option options [Boolean] exact            Control whether `is` expressions in the given XPath match exactly or partially. Defaults to {Capybara.configure exact}.\n      #   @option options [Symbol] match        The matching strategy to use. Defaults to {Capybara.configure match}.\n      #\n      # @return [Capybara::Node::Element]      The found element\n      # @raise  [Capybara::ElementNotFound]    If the element can't be found before time expires\n      #\n      def find(*args, **options, &optional_filter_block)\n        options[:session_options] = session_options\n        count_options = options.slice(*Capybara::Queries::BaseQuery::COUNT_KEYS)\n        unless count_options.empty?\n          Capybara::Helpers.warn(\n            \"'find' does not support count options (#{count_options}) ignoring. \" \\\n            \"Called from: #{Capybara::Helpers.filter_backtrace(caller)}\"\n          )\n        end\n        synced_resolve Capybara::Queries::SelectorQuery.new(*args, **options, &optional_filter_block)\n      end\n\n      ##\n      #\n      # Find an {Capybara::Node::Element} based on the given arguments that is also an ancestor of the element called on.\n      # {#ancestor} will raise an error if the element is not found.\n      #\n      # {#ancestor} takes the same options as {#find}.\n      #\n      #     element.ancestor('#foo').find('.bar')\n      #     element.ancestor(:xpath, './/div[contains(., \"bar\")]')\n      #     element.ancestor('ul', text: 'Quox').click_link('Delete')\n      #","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/teamcapybara/capybara/blob/15b5fdb76e972e9623d5af2123ed3755594f9732/lib/capybara/node/finders.rb#L37-L73","documentation":"find resolves exactly one element and returns it, so the count constraints :count, :minimum, :maximum and :between (Capybara::Queries::BaseQuery::COUNT_KEYS) are meaningless there. When any of them is passed, Capybara emits this warning, strips/ignores the count options, and runs the query anyway; the count has no effect on the result.","triggerScenarios":"page.find('.items .item', count: 3); find('tr', minimum: 1); copying an options hash from have_selector('.item', count: 2) or all('li', maximum: 5) into a find call.","commonSituations":"Developer intends to assert how many elements exist but uses the single-element finder; refactoring between all/find leaves stale options; shared option hashes reused across finders and matchers, producing noisy warnings in CI logs.","solutions":["Assert counts with a matcher: expect(page).to have_selector('.item', count: 3).","If you only need an element, drop the count option from find entirely.","If you need the collection, use all('.item') / find_all('.item'), where count options are honored."],"exampleFix":"# before\npage.find('.items .item', count: 3) # warns; count ignored\n\n# after\nexpect(page).to have_selector('.items .item', count: 3)","handlingStrategy":"validation","validationCode":"COUNT_KEYS = %i[count minimum maximum between].freeze\n\n# Before calling find with a dynamic options hash:\nfind_options = options.except(*COUNT_KEYS)\nif (options.keys & COUNT_KEYS).any?\n  warn \"Moving count options #{options.slice(*COUNT_KEYS)} to a matcher\"\n  expect(page).to have_selector(selector, **options.slice(*COUNT_KEYS))\nend\nfind(selector, **find_options)","typeGuard":"def find_options?(opts)\n  (opts.keys & %i[count minimum maximum between]).empty?\nend","tryCatchPattern":null,"preventionTips":["Use find only for single-element lookups; express quantity expectations with have_selector/have_css matchers.","Lint specs for find(.*count:) with a simple grep in CI to catch copy-paste drift from all/matchers.","Keep locator option hashes scoped per call site instead of sharing one hash across finders and matchers."],"tags":["capybara","finder","options-misuse","deprecation","ruby"],"backgroundTag":"unsupported-option-warning","analyzedSha":"15b5fdb76e972e9623d5af2123ed3755594f9732","analyzedAt":"2026-08-21T16:53:45.588Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}