Sha256: f374786d8f6c17977ef7d6c23cabbbeeacaca4cf045a126e77e3ee60e7f77d3f

Contents?: true

Size: 1017 Bytes

Versions: 31

Compression:

Stored size: 1017 Bytes

Contents

# encoding: utf-8
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

    #
    # Set the file field to the given path
    #
    # @param [String] a path
    #
    def value=(path)
      assert_exists
      path = path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
      @element.send_keys path
    end
  end

  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
    def element_class
      FileField
    end
  end # FileFieldCollection
end # Watir

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
watir-webdriver-0.6.1 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.6.0 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.8 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.7 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.6 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.5 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.4 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.3 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.2 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.1 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.5.0 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.4.1 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.4.0 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.3.9 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.3.8 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.3.7 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.3.6 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.3.5 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.3.4 lib/watir-webdriver/elements/file_field.rb
watir-webdriver-0.3.3 lib/watir-webdriver/elements/file_field.rb