{"record":{"id":"24f3ebfb133f17e8","repo":"teamcapybara/capybara","slug":"this-driver-doesn-t-support-case-insensitive-attri","errorCode":null,"errorMessage":"This driver doesn't support case insensitive attribute matching when using CSS base selectors","messagePattern":"This driver doesn't support case insensitive attribute matching when using CSS base selectors","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/capybara/rack_test/driver.rb","lineNumber":81,"sourceCode":"\n  def response_headers\n    response.headers\n  end\n\n  def status_code\n    response.status\n  end\n\n  def find_xpath(selector)\n    browser.find(:xpath, selector)\n  end\n\n  def find_css(selector)\n    browser.find(:css, selector)\n  rescue Nokogiri::CSS::SyntaxError\n    raise unless selector.include?(' i]')\n\n    raise ArgumentError, \"This driver doesn't support case insensitive attribute matching when using CSS base selectors\"\n  end\n\n  def html\n    browser.html\n  end\n\n  def dom\n    browser.dom\n  end\n\n  def title\n    browser.title\n  end\n\n  def reset!\n    @browser = nil\n  end\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/teamcapybara/capybara/blob/15b5fdb76e972e9623d5af2123ed3755594f9732/lib/capybara/rack_test/driver.rb#L63-L99","documentation":"The rack_test driver translates CSS selectors via Nokogiri's CSS parser, which does not accept the CSS4 case-insensitivity flag (the trailing ' i' inside an attribute selector) in all positions Capybara generates it. find_css rescues Nokogiri::CSS::SyntaxError and, if the selector contains the ' i]' marker, re-raises ArgumentError explaining the limitation. So a case-insensitive attribute selector works in a real browser driver but not under rack_test.","triggerScenarios":"find(:css, \"input[placeholder='email' i]\"); or a casefold regexp filter that makes the CSS builder emit [attr*='...' i], e.g. find(:css, '.menu', class: /nav-item/i) - under the rack_test driver the resulting selector hits Nokogiri and fails.","commonSituations":"Copying selectors from DevTools or browser-only specs (where ' i]' is valid CSS4) into rack_test feature specs; using case-insensitive regexp filters with CSS-format selectors while running the default :rack_test driver.","solutions":["Rewrite the query as XPath with case-insensitive matching (XPath translate() or the xpath gem's case-insensitive helpers).","Drop case-insensitivity under rack_test and match the literal casing in the selector string.","Move the affected spec to a JS-capable driver (selenium, cuprite) whose engine supports the flag - tag it js: true.","Gate the assertion by driver so the case-insensitive path only runs where supported."],"exampleFix":"# before\nfind(:css, \"input[placeholder='email' i]\")\n\n# after\nfind(:xpath, \"//input[translate(@placeholder,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='email']\")","handlingStrategy":"fallback","validationCode":"def css_supported?(selector)\n  return true if Capybara.current_driver != :rack_test\n  !selector.include?(' i]')\nend\n\nselector = \"input[placeholder='email' i]\"\nraise ArgumentError, 'case-insensitive CSS unsupported under rack_test' unless css_supported?(selector)","typeGuard":"def case_insensitive_css?(sel)\n  sel.include?(' i]')\nend","tryCatchPattern":"begin\n  find(:css, \"input[placeholder='email' i]\")\nrescue ArgumentError\n  find(:xpath, \"//input[translate(@placeholder,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='email']\")\nend","preventionTips":["Prefer XPath with translate() for case-insensitive attribute matching in driver-agnostic helpers.","Keep case-insensitive CSS4 selectors inside js: true (selenium/cuprite) specs only."],"tags":["ruby","capybara","rack-test","css","nokogiri"],"backgroundTag":"unsupported-css-selector","analyzedSha":"15b5fdb76e972e9623d5af2123ed3755594f9732","analyzedAt":"2026-08-21T16:53:45.588Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}