Sha256: f376a80f01734a3e7e62587c17e2abaf396a3f5e08a580bfa48e0e53a1ea03f9

Contents?: true

Size: 946 Bytes

Versions: 17

Compression:

Stored size: 946 Bytes

Contents

module Watir
  class FileField < Input

    #
    # Set the file field to the given path
    #
    # @param [String] a 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

17 entries across 17 versions & 1 rubygems

Version Path
watir-6.7.3 lib/watir/elements/file_field.rb
watir-6.7.2 lib/watir/elements/file_field.rb
watir-6.7.1 lib/watir/elements/file_field.rb
watir-6.7.0 lib/watir/elements/file_field.rb
watir-6.6.3 lib/watir/elements/file_field.rb
watir-6.6.2 lib/watir/elements/file_field.rb
watir-6.6.1 lib/watir/elements/file_field.rb
watir-6.6.0 lib/watir/elements/file_field.rb
watir-6.5.0 lib/watir/elements/file_field.rb
watir-6.4.3 lib/watir/elements/file_field.rb
watir-6.4.2 lib/watir/elements/file_field.rb
watir-6.4.1 lib/watir/elements/file_field.rb
watir-6.4.0 lib/watir/elements/file_field.rb
watir-6.4.0.rc2 lib/watir/elements/file_field.rb
watir-6.4.0.rc1 lib/watir/elements/file_field.rb
watir-6.3.0 lib/watir/elements/file_field.rb
watir-6.2.1 lib/watir/elements/file_field.rb