Sha256: f9d8e191e469df4a0fb1774ae876b76846d0fd68340bf6ea2b2749cad174fe64

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

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

    # Sets text of the text field.
    # @param [String] text of the field to set.
    # @raise [UnknownTextFieldException] if the text field doesn't exist.
    def set(text)
      wait_until_exists
      @text_field.set(text)
    end

    # Clears text field's text.
    # @raise [UnknownTextFieldException] if the text field doesn't exist.
    def clear
      wait_until_exists
      @text_field.clear
    end

    # Returns text field's current value (text).
    # @return [String] the value (text) of the text field.
    # @raise [UnknownTextFieldException] if the text field doesn't exist.
    def value
      wait_until_exists
      @text_field.value
    end

    # Checks if the text field exists.
    # @return [Boolean] true if text field exists, false otherwise.
    def exists?
      @text_field.exists?
    end

    def hwnd
      wait_until_exists
      @text_field.hwnd
    end

    alias_method :exist?, :exists?

    # Allows to execute specific {Adapter} methods not part of the public API.
    def method_missing(name, *args)
      @text_field.send(name, *args)
    end

    private

    def wait_until_exists
      WaitHelper.wait_until {exists?}
    rescue WaitHelper::TimeoutError
      raise UnknownTextFieldException, "Text field #{@locators.inspect} doesn't exist on window #{@window.locators.inspect}!" unless exists?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rdp-rautomation-0.6.3.1 lib/rautomation/text_field.rb