Sha256: c011a390715e395e6c3071b189febc88fb8efea13746ee1ce2f394b69280ea2e

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

module RAutomation
  class TextField
    # This constructor is meant to be accessed only through RAutomation::Window#text_field method.
    def initialize(window, locators) #:nodoc:
      @window = window
      @locators = locators
      @text_field = @window.text_field(@locators)
    end

    # Sets TextField's text to +text+.
    #
    # Raises an UnknownTextFieldException if the TextField itself doesn't exist.
    def set(text)
      assert_exists
      @text_field.set(text)
    end

    # Clears TextField's text.
    #
    # Raises an UnknownTextFieldException if the TextField itself doesn't exist.
    def clear
      assert_exists
      @text_field.clear
    end

    # Returns TextField's text.
    #
    # Raises an UnknownTextFieldException if the TextField itself doesn't exist.
    def value
      assert_exists
      @text_field.value
    end

    # Returns true if TextField exists, false otherwise.
    def exists?
      @text_field.exists?
    end

    alias_method :exist?, :exists?

    private

    def assert_exists
      raise UnknownTextFieldException.new("Text field '#{@locators.inspect}' doesn't exist on window '#{@window.locators.inspect}'!") unless exists?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rautomation-0.0.3 lib/rautomation/text_field.rb
rautomation-0.0.2 lib/rautomation/text_field.rb
rautomation-0.0.1 lib/rautomation/text_field.rb