Class: RAutomation::Adapter::WinFfi::SelectList

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

Defined Under Namespace

Classes: SelectListOption

Instance Method Summary collapse

Methods inherited from Control

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

Constructor Details

#initialize(window, locators) ⇒ SelectList

Returns a new instance of SelectList.



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

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

Instance Method Details

#control_hwnd



67
68
69
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 67

def control_hwnd
  @hwnd
end

#exist?Boolean Also known as: exists?

Returns:

  • (Boolean)


71
72
73
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 71

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

#option(options)



58
59
60
61
62
63
64
65
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 58

def option(options)
  item_count.times do |item_no|
    item = Functions.retrieve_combobox_item_text(@hwnd, item_no)
    return SelectListOption.new(self, item, item_no) if options[:text] == item
  end

  nil
end

#options(options = {})



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 37

def options(options = {})
  items = []

  item_count.times do |item_no|
    item = Functions.retrieve_combobox_item_text(@hwnd, item_no)

    if options[:text] 
      items.push(SelectListOption.new(self, item, item_no)) if options[:text] == item
    else
      items.push(SelectListOption.new(self, item, item_no))
    end
  end

  items
end

#value



53
54
55
56
# File 'lib/rautomation/adapter/win_ffi/select_list.rb', line 53

def value
  selected_option = options.find {|option| option.selected?}
  selected_option ? selected_option.text : ""
end