Support multiple file upload with Firefox
This commit is contained in:
parent
869c160fe0
commit
59fbd4107f
|
@ -279,10 +279,11 @@ private
|
|||
|
||||
def set_file(value) # rubocop:disable Naming/AccessorMethodName
|
||||
path_names = value.to_s.empty? ? [] : value
|
||||
if driver.chrome?
|
||||
native.send_keys(Array(path_names).join("\n"))
|
||||
if driver.marionette?
|
||||
native.clear
|
||||
Array(path_names).each { |p| native.send_keys(p) }
|
||||
else
|
||||
native.send_keys(*path_names)
|
||||
native.send_keys(Array(path_names).join("\n"))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ Capybara::SpecHelper.spec "#attach_file" do
|
|||
end
|
||||
|
||||
it "should not break when using HTML5 multiple file input uploading multiple files" do
|
||||
pending "Selenium is buggy on this, see http://code.google.com/p/selenium/issues/detail?id=2239" if @session.respond_to?(:mode) && @session.mode.to_s =~ /^selenium_(firefox|marionette)/
|
||||
@session.attach_file("Multiple Documents",
|
||||
[@test_file_path, @another_test_file_path].map { |f| with_os_path_separators(f) })
|
||||
@session.click_button('Upload Multiple')
|
||||
|
@ -86,6 +85,16 @@ Capybara::SpecHelper.spec "#attach_file" do
|
|||
@session.click_button('Upload Empty Multiple')
|
||||
expect(@session).to have_content("Successfully ignored empty file field")
|
||||
end
|
||||
|
||||
it "should not append files to already attached" do
|
||||
@session.attach_file "Multiple Documents", with_os_path_separators(@test_file_path)
|
||||
@session.attach_file("Multiple Documents",
|
||||
[@test_file_path, @another_test_file_path].map { |f| with_os_path_separators(f) })
|
||||
@session.click_button('Upload Multiple')
|
||||
expect(@session.body).to include("2 | ") # number of files
|
||||
expect(@session.body).to include(File.read(@test_file_path))
|
||||
expect(@session.body).to include(File.read(@another_test_file_path))
|
||||
end
|
||||
end
|
||||
|
||||
context "with a locator that doesn't exist" do
|
||||
|
|
Loading…
Reference in New Issue