Class: RAutomation::Adapter::Autoit::TextField

Inherits:
Object
  • Object
show all
Includes:
WaitHelper
Defined in:
lib/rautomation/adapter/autoit/text_field.rb

Constant Summary collapse

DEFAULT_LOCATORS =

Default locators used for searching text fields.

{:class => /edit/i}

Instance Method Summary collapse

Constructor Details

#initialize(window, locators) ⇒ TextField

Note:

this method is not meant to be accessed directly, but only through Window#text_field!

Creates the text field object.

Parameters:

  • window (RAutomation::Window)

    this text field belongs to.

  • locators (Hash)

    for searching the text field.

Options Hash (locators):

  • :class (String, Regexp)

    Internal class name of the text field

  • :value (String, Regexp)

    Value (text) of the text field

  • :id (String, Integer)

    Internal ID of the text field

  • :index (String, Integer)

    0-based index to specify n-th text field if all other criteria match

See Also:



28
29
30
31
# File 'lib/rautomation/adapter/autoit/text_field.rb', line 28

def initialize(window, locators)
  @window = window
  extract(locators)
end

Instance Method Details

#clear

See Also:



49
50
51
# File 'lib/rautomation/adapter/autoit/text_field.rb', line 49

def clear
  set ""
end

#exists?Boolean

Returns:

  • (Boolean)

See Also:



59
60
61
# File 'lib/rautomation/adapter/autoit/text_field.rb', line 59

def exists?
  hwnd != 0
end

#hwnd



33
34
35
# File 'lib/rautomation/adapter/autoit/text_field.rb', line 33

def hwnd
  Window.autoit.ControlGetHandle(@window.locator_hwnd, "", @autoit_locators).hex
end

#set(text)

See Also:



38
39
40
41
42
43
44
45
46
# File 'lib/rautomation/adapter/autoit/text_field.rb', line 38

def set(text)
  wait_until do
    @window.activate
    @window.active? &&
            Window.autoit.ControlFocus(@window.locator_hwnd, "", @autoit_locators) == 1 &&
            Window.autoit.ControlSetText(@window.locator_hwnd, "", @autoit_locators, text) == 1 &&
            value == text
  end
end

#value

See Also:



54
55
56
# File 'lib/rautomation/adapter/autoit/text_field.rb', line 54

def value
  Window.autoit.ControlGetText(@window.locator_hwnd, "", @autoit_locators)
end