Class: RAutomation::Adapter::WinFfi::TextField

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

Constant Summary collapse

DEFAULT_LOCATORS =

Default locators used for searching text fields.

{:class => /edit/i}

Instance Method Summary collapse

Methods inherited from Control

#assert_enabled, #click, #disabled?, #enabled?, #has_focus?, #initialize, #matches_type, #set_focus, #uia_control

Constructor Details

This class inherits a constructor from RAutomation::Adapter::WinFfi::Control

Instance Method Details

#clear

See Also:



26
27
28
29
# File 'lib/rautomation/adapter/win_ffi/text_field.rb', line 26

def clear
  raise "Cannot set value on a disabled text field" if disabled?
  set ""
end

#exist?Boolean Also known as: exists?

Returns:

  • (Boolean)


41
42
43
# File 'lib/rautomation/adapter/win_ffi/text_field.rb', line 41

def exist?
  @locators[:id].nil? ? super : super && matches_type(Constants::UIA_EDIT_CONTROL_TYPE)
end

#hwnd

See Also:



37
38
39
# File 'lib/rautomation/adapter/win_ffi/text_field.rb', line 37

def hwnd
  Functions.control_hwnd(@window.hwnd, @locators)
end

#set(text)

See Also:



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rautomation/adapter/win_ffi/text_field.rb', line 12

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

#value

See Also:



32
33
34
# File 'lib/rautomation/adapter/win_ffi/text_field.rb', line 32

def value
  Functions.control_value(hwnd)
end