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)