I have created custom upload form using the following html stack:
<form>
<label></label>
<input type="file">
</form>
The file field is hidden via css with display: none
property. So the file attach dialogue is being called by user when she clicks on label (which is custom styled).
In my feature test I can't attach a file since the input field is hidden. I've tried few possible solutions, but neither of them work:
find(:xpath, '//input', visible: false).set(some_file_path)
or
within('form') do
attach_file(:input, some_file_path, visible: false)
end
And many others. All of the time I end up with Failed to click element at unknown position error. Once I remove the label overlapping the input field, make it visible and run my spec everything passes. So the issue here is the fact that:
- The input file field has
display: none
property (and by thus is can't be found) - There is a label overlapping the hidden file field (probably)
Is there any way to make Capybara with Capybara-webkit driver handle this delicate situation in some sane way?