Sha256: 32e1b1a300e75e0dc2f7ac2e94097e8fa0f6d21406452aff6cfd35a31f762f54

Contents?: true

Size: 943 Bytes

Versions: 9

Compression:

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

9 entries across 9 versions & 1 rubygems

Version Path
watir-6.16.5 lib/watir/elements/file_field.rb
watir-6.16.4 lib/watir/elements/file_field.rb
watir-6.16.3 lib/watir/elements/file_field.rb
watir-6.16.2 lib/watir/elements/file_field.rb
watir-6.16.1 lib/watir/elements/file_field.rb
watir-6.16.0 lib/watir/elements/file_field.rb
watir-6.15.1 lib/watir/elements/file_field.rb
watir-6.15.0 lib/watir/elements/file_field.rb
watir-6.14.0 lib/watir/elements/file_field.rb