Sha256: 9f8eb26b42f09db50618aa5310e169f6fe5a7aa074f8bcf257be4264382a7ace

Contents?: true

Size: 936 Bytes

Versions: 7

Compression:

Stored size: 936 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(opts = {})
      FileField.new(self, opts.merge(tag_name: 'input', type: 'file'))
    end

    def file_fields(opts = {})
      FileFieldCollection.new(self, opts.merge(tag_name: 'input', type: 'file'))
    end
  end # Container

  class FileFieldCollection < InputCollection
  end # FileFieldCollection
end # Watir

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
watir-7.1.0 lib/watir/elements/file_field.rb
watir-7.0.0 lib/watir/elements/file_field.rb
watir-7.0.0.beta5 lib/watir/elements/file_field.rb
watir-7.0.0.beta4 lib/watir/elements/file_field.rb
watir-7.0.0.beta3 lib/watir/elements/file_field.rb
watir-7.0.0.beta2 lib/watir/elements/file_field.rb
watir-7.0.0.beta1 lib/watir/elements/file_field.rb