Class: RAutomation::Adapter::MsUia::TextField

Inherits:
Control
  • Object
show all
Includes:
Locators, WaitHelper
Defined in:
lib/rautomation/adapter/ms_uia/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, #bounding_rectangle, #click, #control_class, #control_name, #disabled?, #enabled?, #focus, #focused?, #get_current_control_type, #initialize, #matches_type?, #new_pid, #uia_element, #visible?

Constructor Details

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

Instance Method Details

#clear

See Also:



27
28
29
30
# File 'lib/rautomation/adapter/ms_uia/text_field.rb', line 27

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

#exist?Boolean Also known as: exists?

Returns:

  • (Boolean)


44
45
46
# File 'lib/rautomation/adapter/ms_uia/text_field.rb', line 44

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

#hwnd

todo - replace with UIA version

See Also:



40
41
42
# File 'lib/rautomation/adapter/ms_uia/text_field.rb', line 40

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

#set(text)

todo - replace with UIA version

See Also:



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

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

todo - replace with UIA version

See Also:



34
35
36
# File 'lib/rautomation/adapter/ms_uia/text_field.rb', line 34

def value
  Functions.control_value(hwnd)
end