Method: Capybara::Selenium::FirefoxNode#set_file
- Defined in:
- lib/capybara/selenium/nodes/firefox_node.rb
#set_file(value) ⇒ Object
rubocop:disable Naming/AccessorMethodName
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/capybara/selenium/nodes/firefox_node.rb', line 26 def set_file(value) # rubocop:disable Naming/AccessorMethodName # By default files are appended so we have to clear here if its multiple and already set driver.execute_script(" if (arguments[0].multiple && arguments[0].files.length){\n arguments[0].value = null;\n }\n JS\n return super if browser_version >= 62.0\n\n # Workaround lack of support for multiple upload by uploading one at a time\n path_names = value.to_s.empty? ? [] : Array(value)\n if (fd = bridge.file_detector) && !driver.browser.respond_to?(:upload)\n path_names.map! { |path| upload(fd.call([path])) || path }\n end\n path_names.each { |path| native.send_keys(path) }\nend\n", self) |