{"record":{"id":"ea8d9df6f891f8cd","repo":"SeleniumHQ/selenium","slug":"you-are-trying-to-upload-something-that-isn-t-a-fi","errorCode":null,"errorMessage":"You are trying to upload something that isn't a file.","messagePattern":"You are trying to upload something that isn't a file\\.","errorType":"exception","errorClass":"Error::WebDriverError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/remote/features.rb","lineNumber":48,"sourceCode":"        }.freeze\n\n        def add_commands(commands)\n          @command_list = command_list.merge(commands)\n        end\n\n        def command_list\n          @command_list ||= REMOTE_COMMANDS\n        end\n\n        def commands(command)\n          command_list[command]\n        end\n\n        def upload(local_file)\n          unless File.file?(local_file)\n            WebDriver.logger.error(\"File detector only works with files. #{local_file.inspect} isn`t a file!\",\n                                   id: :file_detector)\n            raise Error::WebDriverError, \"You are trying to upload something that isn't a file.\"\n          end\n\n          execute :upload_file, {}, {file: Zipper.zip_file(local_file)}\n        end\n\n        def upload_if_necessary(keys)\n          local_files = keys.first&.split(\"\\n\")&.filter_map { |key| @file_detector.call(Array(key)) }\n          return keys unless local_files&.any?\n\n          keys = local_files.map { |local_file| upload(local_file) }\n          Array(keys.join(\"\\n\"))\n        end\n\n        def downloadable_files\n          execute :get_downloadable_files\n        end\n\n        def download_file(name)","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/features.rb#L30-L66","documentation":"Raised as Error::WebDriverError by the upload method (mixed in via Remote::Features) when the file_detector callback returned a path that is not a regular file (File.file? returns false). The upload flow zips the local file and sends it to the remote server via execute :upload_file; only real files can be zipped, so directories, broken symlinks, devices, or non-existent paths are rejected.","triggerScenarios":"Calling driver.send_keys with a path to a directory, a non-existent file, a broken symlink, or a special device file. The default file_detector or a custom one returning a path string where File.file? is false. Using send_keys with text that the file_detector misinterprets as a file path.","commonSituations":"Uploading from a path that doesn't exist in the test runner's filesystem (common in containerized or CI environments where the file is on a different volume). Race condition where the file is deleted between detection and upload. Passing an absolute path from a different OS (Windows path on Linux runner). A custom file_detector with a bug returning directory paths.","solutions":["Verify the file exists and is a regular file before triggering upload: File.file?(path).","Use absolute paths and ensure the file is present on the machine running the WebDriver client (not just the remote node).","If using a custom file_detector, ensure it only returns paths that pass File.file?.","In CI, copy test fixtures into a known local directory and reference those paths."],"exampleFix":"# before\nupload_element.send_keys('/data/uploads/avatar')  # is a directory\n\n# after\nupload_element.send_keys('/data/uploads/avatar.png')  # a real file\n# guard:\npath = '/data/uploads/avatar.png'\nupload_element.send_keys(path) if File.file?(path)","handlingStrategy":"validation","validationCode":"# Validate file before triggering upload:\nfilepath = '/path/to/file.png'\nraise ArgumentError, \"#{filepath} is not a regular file\" unless File.file?(filepath)\nupload_element.send_keys(filepath)","typeGuard":"def uploadable_file?(path)\n  path.is_a?(String) && File.file?(path)\nend","tryCatchPattern":"begin\n  upload_element.send_keys(filepath)\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  raise unless e.message.include?(\"isn't a file\")\n  # locate the real file or skip the upload\n  raise \"File not found for upload: #{filepath}\"\nend","preventionTips":["Use absolute paths and verify File.file?(path) before upload.","Ensure test fixtures exist on the client machine, not just the remote node.","If using a custom file_detector, ensure it only returns regular file paths.","In CI, copy fixtures to a known local directory first."],"tags":["file-upload","file-detector","validation","filesystem"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}