{"record":{"id":"f2334aaebde048d1","repo":"teamcapybara/capybara","slug":"boolean-exact-text-option-is-not-supported-when","errorCode":null,"errorMessage":"Boolean 'exact_text' option is not supported when 'text' option is a Regexp - ignoring","messagePattern":"Boolean 'exact_text' option is not supported when 'text' option is a Regexp - ignoring","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/capybara/queries/selector_query.rb","lineNumber":31,"sourceCode":"      VALID_MATCH = %i[first smart prefer_exact one].freeze\n\n      def initialize(*args,\n                     session_options:,\n                     enable_aria_label: session_options.enable_aria_label,\n                     enable_aria_role: session_options.enable_aria_role,\n                     test_id: session_options.test_id,\n                     selector_format: nil,\n                     order: nil,\n                     **options,\n                     &filter_block)\n        @resolved_node = nil\n        @resolved_count = 0\n        @options = options.dup\n        @order = order\n        @filter_cache = Hash.new { |hsh, key| hsh[key] = {} }\n\n        if @options[:text].is_a?(Regexp) && [true, false].include?(@options[:exact_text])\n          Capybara::Helpers.warn(\n            \"Boolean 'exact_text' option is not supported when 'text' option is a Regexp - ignoring\"\n          )\n        end\n\n        super(@options)\n        self.session_options = session_options\n\n        @selector = Selector.new(\n          find_selector(args[0].is_a?(Symbol) ? args.shift : args[0]),\n          config: {\n            enable_aria_label: enable_aria_label,\n            enable_aria_role: enable_aria_role,\n            test_id: test_id\n          },\n          format: selector_format\n        )\n\n        @locator = args.shift","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/teamcapybara/capybara/blob/15b5fdb76e972e9623d5af2123ed3755594f9732/lib/capybara/queries/selector_query.rb#L13-L49","documentation":"The exact_text option (true/false) controls exact versus substring matching only when the text option is a String. When text is a Regexp, exactness has no meaning, so SelectorQuery's initializer warns and ignores the boolean. The regexp itself is still applied unchanged.","triggerScenarios":"page.find('div', text: /Total/, exact_text: true); a shared options hash like { text: /#{term}/i, exact_text: true } reused across find/match calls; expect(page).to have_selector('p', text: /foo/, exact_text: false).","commonSituations":"Option hashes written for String text lookups later reused with Regexp text; developers trying to anchor a regex match through exact_text instead of regex anchors.","solutions":["Remove exact_text whenever text is a Regexp.","If you meant fully anchored matching, encode it in the regexp: text: /\\ATotal\\z/.","If you want exact matching, pass a String with exact_text: true: find('div', text: 'Total', exact_text: true)."],"exampleFix":"# before\npage.find('div', text: /Total/, exact_text: true) # warns; exact_text ignored\n\n# after\npage.find('div', text: /\\ATotal\\z/)","handlingStrategy":"validation","validationCode":"# Strip exact_text before any finder/matcher when text is a Regexp\nquery_opts = opts.dup\nquery_opts.delete(:exact_text) if query_opts[:text].is_a?(Regexp)\npage.find(selector, **query_opts)","typeGuard":"def consistent_text_options?(opts)\n  !(opts[:text].is_a?(Regexp) && [true, false].include?(opts[:exact_text]))\nend","tryCatchPattern":null,"preventionTips":["Reach for regexp anchors (/\\A...\\z/) instead of exact_text when matching with a Regexp.","Do not share one options hash between String-text and Regexp-text queries; build options per call.","Treat this warning as a code smell: the exactness intent was silently dropped, so confirm the match semantics you actually wanted."],"tags":["capybara","finder","options-misuse","text-matching","ruby"],"backgroundTag":"unsupported-option-warning","analyzedSha":"15b5fdb76e972e9623d5af2123ed3755594f9732","analyzedAt":"2026-08-21T16:53:45.588Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}