Module: Frank::Cucumber::FrankMacHelper

Included in:
Frank::Console
Defined in:
lib/frank-cucumber/frank_mac_helper.rb

Instance Method Summary collapse

Instance Method Details

#bring_to_front(selector) ⇒ Object

Brings the selected application or window to the front.



54
55
56
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 54

def bring_to_front( selector )
  perform_action_on_selector( 'FEX_raise', selector )
end

#cancel(selector) ⇒ Object

Cancels the current action, such as editing a text field.



59
60
61
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 59

def cancel( selector )
  perform_action_on_selector( 'FEX_cancel', selector )
end

#click(selector) ⇒ Object

Performs a click at the center of the selected object.

This method creates CGEvents to move and click the mouse. Before calling this method, you should make sure that the element that you want to click is frontmost by calling bring_to_front.

This method is designed to act on a single object, so do not pass a selector that will return multiple objects.



15
16
17
18
19
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 15

def click ( selector )
  frame = accessibility_frame(selector)
  frankly_map( selector, 'FEX_mouseDownX:y:', frame.center.x, frame.center.y )
  frankly_map( selector, 'FEX_mouseUpX:y:', frame.center.x, frame.center.y )
end

#collapse_row(selector) ⇒ Object

Collapses the row the selector belongs to in an NSOutlineView. Do not expand more than one row at a time.



104
105
106
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 104

def collapse_row( selector )
  perform_action_on_selector( 'FEX_collapse', selector )
end

#confirm(selector) ⇒ Object

Finishes the current action, such as editing a text field.



64
65
66
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 64

def confirm( selector )
  perform_action_on_selector( 'FEX_confirm', selector )
end

#decrement_value(selector) ⇒ Object

Decrements the value of NSSliders, NSSteppers, and similar controls



69
70
71
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 69

def decrement_value( selector )
  perform_action_on_selector( 'FEX_decrement', selector )
end

#delete_value(selector) ⇒ Object

Deletes the user-inputted value



74
75
76
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 74

def delete_value( selector )
  perform_action_on_selector( 'FEX_delete', selector )
end

#double_click(selector) ⇒ Object

Performs a double-click at the center of the selected object.

This method creates CGEvents to move and click the mouse. Before calling this method, you should make sure that the element that you want to click is frontmost by calling bring_to_front.

This method is designed to act on a single object, so do not pass a selector that will return multiple objects.



29
30
31
32
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 29

def double_click ( selector )
  click(selector)
  click(selector)
end

#expand_row(selector) ⇒ Object

Expands the row the selector belongs to in an NSOutlineView. Do not expand more than one row at a time.



98
99
100
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 98

def expand_row( selector )
  perform_action_on_selector( 'FEX_expand', selector )
end

#increment_value(selector) ⇒ Object

Increments the value of NSSliders, NSSteppers, and similar controls



79
80
81
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 79

def increment_value( selector )
  perform_action_on_selector( 'FEX_increment', selector )
end

#perform_action_on_selector(action, selector) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 35

def perform_action_on_selector( action, selector )
  touch_successes = frankly_map( selector, action )
  raise "could not find anything matching [#{selector}] which supports that action" if touch_successes == nil or touch_successes.empty?
  raise "some objects do not support that action" if touch_successes.include?(false)
end

#pick(selector) ⇒ Object

Selects a menu item. This action is considered “outdated” by the Accessibility API, so don’t use it without a good reason.



85
86
87
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 85

def pick( selector )
  perform_action_on_selector( 'FEX_pick', selector )
end

#row_is_expanded(selector) ⇒ Boolean

expanded

Returns:

  • (Boolean)

    whether the rows the selectors belong to in an NSOutlineView are all



110
111
112
113
114
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 110

def row_is_expanded( selector )
  successes = frankly_map( selector, "FEX_isExpanded" )
  return false if successes == nil or successes.empty?
  return !successes.include?(false)
end

#show_menu(selector) ⇒ Object

Shows the contextual menu associated with the selector. This is the menu that would appear if the user right-clicked the selector, or, in some cases, held down the left mouse button on the selector.



92
93
94
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 92

def show_menu( selector )
  perform_action_on_selector( 'FEX_showMenu', selector )
end

#simulate_click(selector) ⇒ Object

Simulates the effect of clicking on the selected objects without actually moving the mouse or clicking.

If the object supports the NSAccessibilityPressAction, that action is performed. Otherwise, if the object is a table cell or row, that row is selected, Otherwise, if the object is an NSView, it is made the first responder, if possible Otherwise, if the object is a menu item, it opens its submenu if it has one, or performs it’s action if not.



49
50
51
# File 'lib/frank-cucumber/frank_mac_helper.rb', line 49

def simulate_click( selector )
  perform_action_on_selector( 'FEX_simulateClick', selector )
end