Class: Osaka::ApplicationWrapper
- Inherits:
-
Object
- Object
- Osaka::ApplicationWrapper
- Defined in:
- lib/osaka/applicationwrapper.rb
Instance Method Summary collapse
- #activate ⇒ Object
- #click(element) ⇒ Object
- #click!(element) ⇒ Object
- #click_and_wait_until_exists(element, wait_condition) ⇒ Object
- #click_and_wait_until_exists!(element, wait_condition) ⇒ Object
- #click_and_wait_until_not_exists(element, wait_condition) ⇒ Object
- #click_and_wait_until_not_exists!(element, wait_condition) ⇒ Object
- #construct_modifier_statement(modifier_keys) ⇒ Object
-
#initialize(name) ⇒ ApplicationWrapper
constructor
A new instance of ApplicationWrapper.
- #keystroke(key, modifier_keys = []) ⇒ Object
- #keystroke!(key, modifier_keys = []) ⇒ Object
- #keystroke_and_wait_until_exists(key, modifier_keys, element) ⇒ Object
- #keystroke_and_wait_until_exists!(key, modifier_keys, element) ⇒ Object
- #quit ⇒ Object
- #set(element, value) ⇒ Object
- #set!(element, value) ⇒ Object
- #system_event(event) ⇒ Object
- #system_event!(event) ⇒ Object
- #tell(command) ⇒ Object
- #wait_until_exists(element_to_wait_for) ⇒ Object
- #wait_until_exists!(element_to_wait_for) ⇒ Object
- #wait_until_not_exists(element_to_wait_for) ⇒ Object
- #wait_until_not_exists!(element_to_wait_for) ⇒ Object
Constructor Details
#initialize(name) ⇒ ApplicationWrapper
Returns a new instance of ApplicationWrapper.
6 7 8 |
# File 'lib/osaka/applicationwrapper.rb', line 6 def initialize(name) @name = name end |
Instance Method Details
#activate ⇒ Object
10 11 12 |
# File 'lib/osaka/applicationwrapper.rb', line 10 def activate tell("activate") end |
#click(element) ⇒ Object
78 79 80 81 |
# File 'lib/osaka/applicationwrapper.rb', line 78 def click(element) activate click!(element) end |
#click!(element) ⇒ Object
74 75 76 |
# File 'lib/osaka/applicationwrapper.rb', line 74 def click!(element) system_event!("click #{element}") end |
#click_and_wait_until_exists(element, wait_condition) ⇒ Object
88 89 90 91 |
# File 'lib/osaka/applicationwrapper.rb', line 88 def click_and_wait_until_exists(element, wait_condition) activate click_and_wait_until_exists!(element, wait_condition) end |
#click_and_wait_until_exists!(element, wait_condition) ⇒ Object
83 84 85 86 |
# File 'lib/osaka/applicationwrapper.rb', line 83 def click_and_wait_until_exists!(element, wait_condition) click!(element) wait_until_exists!(wait_condition) end |
#click_and_wait_until_not_exists(element, wait_condition) ⇒ Object
98 99 100 101 |
# File 'lib/osaka/applicationwrapper.rb', line 98 def click_and_wait_until_not_exists(element, wait_condition) activate click_and_wait_until_not_exists!(element, wait_condition) end |
#click_and_wait_until_not_exists!(element, wait_condition) ⇒ Object
93 94 95 96 |
# File 'lib/osaka/applicationwrapper.rb', line 93 def click_and_wait_until_not_exists!(element, wait_condition) click!(element) wait_until_not_exists!(wait_condition) end |
#construct_modifier_statement(modifier_keys) ⇒ Object
49 50 51 52 53 |
# File 'lib/osaka/applicationwrapper.rb', line 49 def construct_modifier_statement(modifier_keys) modified_key_string = [ modifier_keys ].flatten.collect! { |mod_key| mod_key.to_s + " down"}.join(", ") modifier_command = " using {#{modified_key_string}}" unless modifier_keys.empty? modifier_command end |
#keystroke(key, modifier_keys = []) ⇒ Object
59 60 61 62 |
# File 'lib/osaka/applicationwrapper.rb', line 59 def keystroke(key, modifier_keys = []) activate keystroke!(key, modifier_keys) end |
#keystroke!(key, modifier_keys = []) ⇒ Object
55 56 57 |
# File 'lib/osaka/applicationwrapper.rb', line 55 def keystroke!(key, modifier_keys = []) system_event!("keystroke \"#{key}\"#{construct_modifier_statement(modifier_keys)}") end |
#keystroke_and_wait_until_exists(key, modifier_keys, element) ⇒ Object
69 70 71 72 |
# File 'lib/osaka/applicationwrapper.rb', line 69 def keystroke_and_wait_until_exists(key, modifier_keys, element) activate keystroke_and_wait_until_exists!(key, modifier_keys, element) end |
#keystroke_and_wait_until_exists!(key, modifier_keys, element) ⇒ Object
64 65 66 67 |
# File 'lib/osaka/applicationwrapper.rb', line 64 def keystroke_and_wait_until_exists!(key, modifier_keys, element) keystroke!(key, modifier_keys) wait_until_exists!(element) end |
#quit ⇒ Object
14 15 16 |
# File 'lib/osaka/applicationwrapper.rb', line 14 def quit tell("quit") end |
#set(element, value) ⇒ Object
107 108 109 110 |
# File 'lib/osaka/applicationwrapper.rb', line 107 def set(element, value) activate set!(element, value) end |
#set!(element, value) ⇒ Object
103 104 105 |
# File 'lib/osaka/applicationwrapper.rb', line 103 def set!(element, value) system_event!("set #{element} to \"#{value}\"") end |
#system_event(event) ⇒ Object
26 27 28 29 |
# File 'lib/osaka/applicationwrapper.rb', line 26 def system_event(event) activate system_event!(event) end |
#system_event!(event) ⇒ Object
22 23 24 |
# File 'lib/osaka/applicationwrapper.rb', line 22 def system_event!(event) ScriptRunner::execute("tell application \"System Events\"; tell process \"#{@name}\"; #{event}; end tell; end tell") end |
#tell(command) ⇒ Object
18 19 20 |
# File 'lib/osaka/applicationwrapper.rb', line 18 def tell(command) ScriptRunner::execute("tell application \"#{@name}\"; #{command}; end tell") end |
#wait_until_exists(element_to_wait_for) ⇒ Object
35 36 37 38 |
# File 'lib/osaka/applicationwrapper.rb', line 35 def wait_until_exists(element_to_wait_for) activate wait_until_exists!(element_to_wait_for) end |
#wait_until_exists!(element_to_wait_for) ⇒ Object
31 32 33 |
# File 'lib/osaka/applicationwrapper.rb', line 31 def wait_until_exists!(element_to_wait_for) system_event!("repeat until exists #{element_to_wait_for}; end repeat") end |
#wait_until_not_exists(element_to_wait_for) ⇒ Object
44 45 46 47 |
# File 'lib/osaka/applicationwrapper.rb', line 44 def wait_until_not_exists(element_to_wait_for) activate wait_until_not_exists!(element_to_wait_for) end |
#wait_until_not_exists!(element_to_wait_for) ⇒ Object
40 41 42 |
# File 'lib/osaka/applicationwrapper.rb', line 40 def wait_until_not_exists!(element_to_wait_for) system_event!("repeat until not exists #{element_to_wait_for}; end repeat") end |