Method: Capybara::Node::Actions#attach_file
- Defined in:
- lib/capybara/node/actions.rb
#attach_file(locator, path, options = {}) ⇒ Object
Find a file field on the page and attach a file given its path. The file field can be found via its name, id or label text.
page.attach_file(locator, '/path/to/file.png')
145 146 147 148 149 150 |
# File 'lib/capybara/node/actions.rb', line 145 def attach_file(locator, path, ={}) Array(path).each do |p| raise Capybara::FileNotFound, "cannot attach file, #{p} does not exist" unless File.exist?(p.to_s) end find(:file_field, locator, ).set(path) end |