WebDriverError: You are trying to upload something that isn't a file.

I am an accomplished Solution Architect, Full Stack Developer and DevOps Specialist with a passion for creative leadership and mentorship, business optimization and technical direction, and ingenious solutions to complex problems.
I am especially interested in App & Web Development, Cyber Security, Cloud Computing, Data Science, Open Source Software, Statistical Analysis and Discrete Mathematics.
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!
[Screenshot Image]: /builds/projects/example/tmp/screenshots/failures_test_should_show_validation_errors_for_password_and_password_confirmation.png
E
Error:
Devise::RegistrationsTest#test_should_show_validation_errors_for_password_and_password_confirmation:
Selenium::WebDriver::Error::WebDriverError: You are trying to upload something that isn't a file.
test/system/devise/registrations_test.rb:42:in `block (2 levels) in <class:RegistrationsTest>'
test/system/devise/registrations_test.rb:37:in `each'
test/system/devise/registrations_test.rb:37:in `block in <class:RegistrationsTest>'
bin/rails test test/system/devise/registrations_test.rb:36
This error corresponds to registrations_test.rb:42, which looks like this:
fill_in 'Password', with: 'test'
And the form field that is being filled in is defined as:
f.password_field :password
The error "You are trying to upload something that isn't a file." makes absolutely no sense, as no file is being uploaded, and the associated screenshot shows that the value test is not being filled in for the password field.
So, what's going on here?
Solution
test value for password fields.For some reason, the value test invokes a file uploader within Selenium WebDriver; hence, the following change fixes the error in Gitlab CI:
fill_in 'Password', with: 'abc-def'
The mystery of why the value test does not work will remain unsolved, though the most likely cause is a Selenium Webdriver bug, but at least system tests work again when executed in CI mode.






