Skip to content

Commit

Permalink
Convert relative paths to absolute when attaching files with the sele…
Browse files Browse the repository at this point in the history
…nium driver
  • Loading branch information
twalpole committed Jun 10, 2019
1 parent acb601c commit c059bfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/capybara/selenium/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def update_value_js(value)

def set_file(value) # rubocop:disable Naming/AccessorMethodName
path_names = value.to_s.empty? ? [] : value
native.send_keys(Array(path_names).join("\n"))
native.send_keys(Array(path_names).map(&File.method(:expand_path)).join("\n"))
end

def set_content_editable(value) # rubocop:disable Naming/AccessorMethodName
Expand Down
7 changes: 7 additions & 0 deletions spec/shared_selenium_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@
session.click_button('Upload Multiple')
expect(session.body).to include('5 | ') # number of files
end

it 'can attach a relative file' do
session.visit('/form')
session.attach_file('Single Document', 'spec/fixtures/capybara.csv')
session.click_button('Upload Single')
expect(session.body).to include('Content-type: text/csv')
end
end

context 'Windows' do
Expand Down

0 comments on commit c059bfe

Please sign in to comment.