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, Fixnum)

    Internal ID of the text field

  • :index (String, Fixnum)

    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:



45
46
47
# File 'lib/rautomation/adapter/autoit/text_field.rb', line 45

def clear
  set ""
end

#exists?Boolean

Returns:

  • (Boolean)

See Also:



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

def exists?
  not Window.autoit.ControlGetHandle(@window.locator_hwnd, "", @autoit_locators).empty?
end

#set(text)

See Also:



34
35
36
37
38
39
40
41
42
# File 'lib/rautomation/adapter/autoit/text_field.rb', line 34

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:



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

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