Class: RAutomation::Adapter::Win32::Control

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

Direct Known Subclasses

Button, Checkbox, Label, ListBox, Radio, SelectList, Table, TextField

Instance Method Summary collapse

Constructor Details

#initialize(window, locators) ⇒ Control

Note:

this method is not meant to be accessed directly

Creates the control object.

Parameters:

  • window (RAutomation::Window)

    this button belongs to.

  • locators (Hash)

    for searching the button.

Options Hash (locators):

  • :value (String, Regexp)

    Value (text) of the button

  • :class (String, Regexp)

    Internal class name of the button

  • :id (String, Integer)

    Internal ID of the button

  • :index (String, Integer)

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

See Also:



17
18
19
20
# File 'lib/rautomation/adapter/win_32/control.rb', line 17

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

Instance Method Details

#class_name



26
27
28
# File 'lib/rautomation/adapter/win_32/control.rb', line 26

def class_name
  Functions.control_class(hwnd)
end

#click



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rautomation/adapter/win_32/control.rb', line 30

def click
  assert_enabled
  clicked = false
  wait_until do
    @window.activate
    @window.active? &&
        focus &&
        Functions.control_click(hwnd) &&
        clicked = true # is clicked at least once

    block_given? ? yield : clicked && !exist?
  end
end

#disabled?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/rautomation/adapter/win_32/control.rb', line 60

def disabled?
  Functions.unavailable? hwnd
end

#enabled?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/rautomation/adapter/win_32/control.rb', line 56

def enabled?
  !disabled?
end

#exist?Boolean Also known as: exists?

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/rautomation/adapter/win_32/control.rb', line 48

def exist?
  !!hwnd
rescue UnknownElementException
  false
end

#focus



64
65
66
67
68
# File 'lib/rautomation/adapter/win_32/control.rb', line 64

def focus
  assert_enabled
  @window.activate
  Functions.set_control_focus hwnd
end

#focused?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/rautomation/adapter/win_32/control.rb', line 70

def focused?
  Functions.has_focus?(hwnd)
end

#hwnd



22
23
24
# File 'lib/rautomation/adapter/win_32/control.rb', line 22

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

#value



74
75
76
# File 'lib/rautomation/adapter/win_32/control.rb', line 74

def value
  Functions.control_value(hwnd)
end