Module: Selenium::WebDriver::DriverExtensions::UploadsFiles Private

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb

Instance Attribute Summary

Instance Attribute Details

#file_detector=(detector) (writeonly)

Set the file detector to pass local files to a remote ::Selenium::WebDriver.

The detector is an object that responds to #call, and when called will determine if the given string represents a file. If it does, the path to the file on the local file system should be returned, otherwise nil or false.


driver = Selenium::WebDriver.for :remote
driver.file_detector = lambda do |args|
   # args => ["/path/to/file"]
   str = args.first.to_s
   str if File.exist?(str)

driver.find_element(:id => "upload").send_keys "/path/to/file"

By default, no file detection is performed.


  • (ArgumentError)
[ GitHub ]

# File 'rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb', line 52

def file_detector=(detector)
  raise ArgumentError, 'detector must respond to #call' unless detector.nil? || detector.respond_to?(:call)

  bridge.file_detector = detector