class RAutomation::Adapter::MsUia::Control
Public Class Methods
new(window, locators)
click to toggle source
Creates the control object. @note this method is not meant to be accessed directly @param [RAutomation::Window] window this button belongs to. @param [Hash] locators for searching the button. @option locators [String, Regexp] :value Value (text) of the button @option locators [String, Regexp] :class Internal class name of the button @option locators [String, Integer] :id Internal ID of the button @option locators [String, Integer] :index 0-based index to specify n-th button if all other criteria match @option locators [String, Boolean] :children_only limit the scope of the search to children only @see RAutomation::Window#button
# File lib/rautomation/adapter/ms_uia/control.rb, line 18 def initialize(window, locators) @window = window extract(locators) end
Public Instance Methods
assert_enabled()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 117 def assert_enabled raise "Cannot interact with disabled control #{@locators.inspect} on window #{@window.locators.inspect}!" if disabled? end
bounding_rectangle()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 83 def bounding_rectangle UiaDll::bounding_rectangle(search_information) end
cached_hwnd()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 23 def cached_hwnd @cached_hwnd ||= UiaDll::cached_hwnd(UiaDll::SearchCriteria.from_locator(@window.hwnd, @locators)) @cached_hwnd == 0 ? nil : @cached_hwnd end
click() { |: clicked && !exist?| ... }
click to toggle source
todo - replace with UIA version
# File lib/rautomation/adapter/ms_uia/control.rb, line 44 def click assert_enabled clicked = false wait_until do @window.activate @window.active? && UiaDll::control_click(search_information) && clicked = true # is clicked at least once block_given? ? yield : clicked && !exist? end end
collapse(which_item)
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 126 def collapse(which_item) UiaDll::collapse_by_value search_information, which_item if which_item.is_a? String UiaDll::collapse_by_index search_information, which_item if which_item.is_a? Integer end
control_class()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 111 def control_class UiaDll::class_name(search_information) end
control_name()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 103 def control_name UiaDll::name(search_information) end
disabled?()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 69 def disabled? !enabled? end
enabled?()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 65 def enabled? UiaDll::is_enabled(search_information) end
exist?()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 57 def exist? begin UiaDll::exists?(search_information) || !!hwnd rescue UnknownElementException false end end
Also aliased as: exists?
expand(which_item)
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 121 def expand(which_item) UiaDll::expand_by_value search_information, which_item if which_item.is_a? String UiaDll::expand_by_index search_information, which_item if which_item.is_a? Integer end
focus()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 78 def focus assert_enabled UiaDll::set_focus(search_information) end
focused?()
click to toggle source
todo - replace with UIA version
# File lib/rautomation/adapter/ms_uia/control.rb, line 74 def focused? UiaDll::is_focused(search_information) end
get_current_control_type()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 95 def get_current_control_type UiaDll::current_control_type(search_information) end
help_text()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 107 def help_text UiaDll::help_text(search_information) end
hwnd()
click to toggle source
todo - replace with UIA version
# File lib/rautomation/adapter/ms_uia/control.rb, line 29 def hwnd Functions.control_hwnd(@window.hwnd, @locators) end
matches_type?(*classes)
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 91 def matches_type?(*classes) classes.include? get_current_control_type end
new_pid()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 99 def new_pid UiaDll::process_id(search_information) end
search_information()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 33 def search_information info = UiaDll::SearchCriteria.from_locator(@window.hwnd, @locators) if info.how == 0 || cached_hwnd info.how = :hwnd info.data = cached_hwnd || hwnd end info end
visible?()
click to toggle source
# File lib/rautomation/adapter/ms_uia/control.rb, line 87 def visible? !UiaDll::is_offscreen(search_information) end