DEV Community

n350071๐Ÿ‡ฏ๐Ÿ‡ต
n350071๐Ÿ‡ฏ๐Ÿ‡ต

Posted on

attach a file in Capybara

๐Ÿ”— Parent Note

๐Ÿค” Situation

You want to atach a file to the input tag.

<label for='data-file'>Data File</label>
<input type="file" name="files" id="attach_files">

๐Ÿ‘ Usual solution

Capybara::Node::Actions#attach_file

attach_file('data-file', 'path/to/file.csv')

๐Ÿฆ„ Workaround solution

find('form input[type="file"]').set('path/to/file.csv')

๐Ÿ“š Attach A File With Capybara - Today I Learned

Top comments (0)