← Back to Upcase

Capybara multiple file uploads overwriting


(David Schlauderaff) #1

I’m trying to use capybara to test a scenario where I upload multiple single image files to multiple inputs. The inputs are hidden, and the problem I am having is that capybara is overwriting each input regardless of the id I specify.

find('#question_image_one', visible: false).set(Rails.root + 'spec/support/features/test_image_1.jpeg')
find('#question_image_two', visible: false).set(Rails.root + 'spec/support/features/test_image_2.jpeg')
find('#question_image_three', visible: false).set(Rails.root + 'spec/support/features/test_image_3.jpeg')

After this runs, the failure screenshot shows that test_image_3.jpeg is uploaded in the #question_image_one field, and all other fields are still empty. I’m baffled as to why capybara seems to be ignoring the specified id. I’ve also tried this with attach_file with the same results.