{"record":{"id":"f11276f92f995380","repo":"teamcapybara/capybara","slug":"capybara-was-unable-to-determine-the-file-input-yo","errorCode":null,"errorMessage":"Capybara was unable to determine the file input you're attaching to","messagePattern":"Capybara was unable to determine the file input you're attaching to","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/capybara/node/actions.rb","lineNumber":294,"sourceCode":"      #   @param [String, Array<String>] paths     The path(s) of the file(s) that will be attached\n      #   @yield Block whose actions will trigger the system file chooser to be shown\n      # @return [Capybara::Node::Element]  The file field element\n      def attach_file(locator = nil, paths, make_visible: nil, **options) # rubocop:disable Style/OptionalArguments\n        if locator && block_given?\n          raise ArgumentError, '`#attach_file` does not support passing both a locator and a block'\n        end\n\n        Array(paths).each do |path|\n          raise Capybara::FileNotFound, \"cannot attach file, #{path} does not exist\" unless File.exist?(path.to_s)\n        end\n        options[:allow_self] = true if locator.nil?\n\n        if block_given?\n          begin\n            execute_script CAPTURE_FILE_ELEMENT_SCRIPT\n            yield\n            file_field = evaluate_script 'window._capybara_clicked_file_input'\n            raise ArgumentError, \"Capybara was unable to determine the file input you're attaching to\" unless file_field\n          rescue ::Capybara::NotSupportedByDriverError\n            warn 'Block mode of `#attach_file` is not supported by the current driver - ignoring.'\n          end\n        end\n        # Allow user to update the CSS style of the file input since they are so often hidden on a page\n        if make_visible\n          ff = file_field || find(:file_field, locator, **options.merge(visible: :all))\n          while_visible(ff, make_visible) { |el| el.set(paths) }\n        else\n          (file_field || find(:file_field, locator, **options)).set(paths)\n        end\n      end\n\n    private\n\n      def find_select_or_datalist_input(from, options)\n        synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do\n          find(:select, from, **options)","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/teamcapybara/capybara/blob/15b5fdb76e972e9623d5af2123ed3755594f9732/lib/capybara/node/actions.rb#L276-L312","documentation":"Error \"Capybara was unable to determine the file input you're attaching to\" thrown in teamcapybara/capybara.","triggerScenarios":"Thrown at lib/capybara/node/actions.rb:294 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"}