I'm trying to test file upload in Capybara, Rails 5.2 feature spec with selenium.
I have been searching for this and found a couple of suggestions. One of them is How do you test uploading a file with Capybara and Dropzone.js?
However, these solutions are for jQuery and Dropzone.js. Does anyone have a solution to this?
99% of the time passing visible: false
as an option to find
indicates you're doing something wrong when testing applications with Capybara.
If all you were trying to do is upload a file when the file input is hidden for styling reasons then the Capybara docs provide all the needed info - https://www.rubydoc.info/gems/capybara/Capybara/Node/Actions#attach_file-instance_method - and an option specifically for dealing with this situation
attach_file(Rails.root.join('spec', 'resources', 'test.png'), make_visible: true)