Sha256: a373aa4f0f48343015e630f9aa8bf1ddeee9afa83a1f174cf3b3fc392def0b52

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

module RAutomation
  module Adapter
    module MsUia
      class TextField < Control
        include WaitHelper
        include Locators

        # Default locators used for searching text fields.
        DEFAULT_LOCATORS = {:class => /edit/i}

        #todo - replace with UIA version
        # @see RAutomation::TextField#set
        def set(text)
          raise "Cannot set value on a disabled text field" if disabled?

          wait_until do
            hwnd = Functions.control_hwnd(@window.hwnd, @locators)
            @window.activate
            @window.active? &&
                    Functions.set_control_focus(hwnd) &&
                    Functions.set_control_text(hwnd, text) &&
                    value == text
          end
        end

        # @see RAutomation::TextField#clear
        def clear
          raise "Cannot set value on a disabled text field" if disabled?
          set ""
        end

        #todo - replace with UIA version
        # @see RAutomation::TextField#value
        def value
          Functions.control_value(hwnd)
        end

        #todo - replace with UIA version
        # @see RAutomation::TextField#hwnd
        def hwnd
          Functions.control_hwnd(@window.hwnd, @locators)
        end

        def exist?
          super && matches_type?(Constants::UIA_EDIT_CONTROL_TYPE)
        end

        alias_method :exists?, :exist?

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rautomation-0.8.0 lib/rautomation/adapter/ms_uia/text_field.rb
rautomation-0.7.3 lib/rautomation/adapter/ms_uia/text_field.rb
rautomation-0.7.2 lib/rautomation/adapter/ms_uia/text_field.rb
rautomation-0.7.1 lib/rautomation/adapter/ms_uia/text_field.rb
rautomation-0.7.0 lib/rautomation/adapter/ms_uia/text_field.rb