Sha256: bfa625ca1a3c526b90e85cb5a5ec12671c97a53e4ab4efc6a804864674f1dd32

Contents?: true

Size: 944 Bytes

Versions: 15

Compression:

Stored size: 944 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

    #
    # 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

15 entries across 15 versions & 1 rubygems

Version Path
watir-6.13.0 lib/watir/elements/file_field.rb
watir-6.12.0 lib/watir/elements/file_field.rb
watir-6.11.0 lib/watir/elements/file_field.rb
watir-6.11.0.beta2 lib/watir/elements/file_field.rb
watir-6.11.0.beta1 lib/watir/elements/file_field.rb
watir-6.10.3 lib/watir/elements/file_field.rb
watir-6.10.2 lib/watir/elements/file_field.rb
watir-6.10.0 lib/watir/elements/file_field.rb
watir-6.9.1 lib/watir/elements/file_field.rb
watir-6.9.0 lib/watir/elements/file_field.rb
watir-6.8.4 lib/watir/elements/file_field.rb
watir-6.8.3 lib/watir/elements/file_field.rb
watir-6.8.2 lib/watir/elements/file_field.rb
watir-6.8.1 lib/watir/elements/file_field.rb
watir-6.8.0 lib/watir/elements/file_field.rb