WebDriverError: You are trying to upload something that isn't a file.
Occasionally, when running Ruby on Rails system tests with Selenium WebDriver in Gitlab CI, you will receive an error such as this:
.....2024-07-31 05:18:51 ERROR Selenium [:file_detector] File detector only works with files. "test" isn`t a file!
[S...
blog.konoson.com2 min read
Great post! Thanks for sharing! I ran into the same issue on a work project and noticed something interesting: we had a folder named
testat the project root. When I experimented with other folder names likelib,app, etc. as values to fill the form field, I got the same error message. Then, when I tried actual filenames likeRakefileorREADME, I wouldn't get the error, but the field would be filled with the path to that file (or a temporary copy of it). So, it turns out that if the string you use to fill the input field matches the path to any file or folder in your project directory, Selenium WebDriver will try to upload that file/folder as if it was a file input, regardless of the actual input type. It's seems a bit less like a Selenium bug, but rather an overly aggressive file detection feature that checks if form values correspond to existing filesystem paths.