Sha256: 773b8b67e7f4b6f4cb1fd8f46a7ab76bfb6812da8e30b6c85cf5a2d7cf9f8cf7

Contents?: true

Size: 964 Bytes

Versions: 4

Compression:

Stored size: 964 Bytes

Contents

module Watir
  class FileField < Input
    #
    # Set the file field to the given path
    #
    # @param [String] path
    # @raise [Errno::ENOENT] if the file doesn't exist
    #

    def set(path)
      raise Errno::ENOENT, path unless File.exist?(path)

      self.value = path
    end
    alias upload set

    #
    # Sets the file field to the given path
    #
    # @param [String] path
    #

    def value=(path)
      path = path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
      element_call { @element.send_keys path }
    end
  end # FileField

  module Container
    def file_field(*args)
      FileField.new(self, extract_selector(args).merge(tag_name: 'input', type: 'file'))
    end

    def file_fields(*args)
      FileFieldCollection.new(self, extract_selector(args).merge(tag_name: 'input', type: 'file'))
    end
  end # Container

  class FileFieldCollection < InputCollection
  end # FileFieldCollection
end # Watir

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
watir-6.19.1 lib/watir/elements/file_field.rb
watir-6.19.0 lib/watir/elements/file_field.rb
watir-6.18.0 lib/watir/elements/file_field.rb
watir-6.17.0 lib/watir/elements/file_field.rb