Module: Calabash::Cucumber::UIA
Overview
Low-level module for interacting directly with UIA See also https://developer.apple.com/library/ios/documentation/ToolsLanguages/Reference/UIAElementClassReference/UIAElement/UIAElement.html Typically used to interact with System or remote views.
Instance Method Summary collapse
-
#uia(command, options = {}) ⇒ Object
Executes raw JavaScript in the UIAutomation environment (using ‘eval`).
-
#uia_call(args_arr, *opts) ⇒ Object
Advanced method used to invoke UIAutomation JavaScript methods on objects found via Calabash queries.
-
#uia_call_windows(args_arr, *opts) ⇒ Object
Similar to ‘uia_call` but searches all windows.
-
#uia_names(*queryparts) ⇒ Array<String>
Invoke a Calabash query inside the UIAutomation Calabash engine - includes all UIAWindows.
-
#uia_query(*queryparts) ⇒ Array<Hash>
Invoke a Calabash query inside the UIAutomation Calabash engine Note that this traverses the UIA (accessibility) hierarchy.
-
#uia_query_windows(*queryparts) ⇒ Array<Hash>
Invoke a Calabash query inside the UIAutomation Calabash engine - includes all UIAWindows.
Methods included from Logging
#calabash_info, #calabash_warn
Instance Method Details
#uia(command, options = {}) ⇒ Object
Executes raw JavaScript in the UIAutomation environment (using ‘eval`).
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/calabash-cucumber/uia.rb', line 19 def uia(command, ={}) # UIA only makes sense if there is a run loop launcher = Calabash::Cucumber::Launcher.launcher_if_used run_loop = launcher && launcher.active? && launcher.run_loop raise ArgumentError, 'the current launcher must be active and be attached to a run_loop' unless run_loop raise ArgumentError, 'please supply :command' unless command case run_loop[:uia_strategy] when :preferences res = http({:method => :post, :path => 'uia'}, {:command => command}.merge()) begin res = JSON.parse(res) rescue TypeError, JSON::ParserError => _ raise "Could not parse response '#{res}'; the app has probably crashed" end if res['outcome'] != 'SUCCESS' raise "uia action failed because: #{res['reason']}\n#{res['details']}" end res['results'].first when :host RunLoop.send_command(run_loop, command) else candidates = [:preferences, :host] raise ArgumentError, "expected '#{run_loop[:uia_strategy]}' to be one of #{candidates}" end end |
#uia_call(args_arr, *opts) ⇒ Object
Advanced method used to invoke UIAutomation JavaScript methods on objects found via Calabash queries
122 123 124 |
# File 'lib/calabash-cucumber/uia.rb', line 122 def uia_call(args_arr, *opts) uia_call_method(:queryEl, args_arr, *opts) end |
#uia_call_windows(args_arr, *opts) ⇒ Object
Similar to ‘uia_call` but searches all windows
128 129 130 |
# File 'lib/calabash-cucumber/uia.rb', line 128 def uia_call_windows(args_arr, *opts) uia_call_method(:queryElWindows, args_arr, *opts) end |
#uia_names(*queryparts) ⇒ Array<String>
Invoke a Calabash query inside the UIAutomation Calabash engine - includes all UIAWindows. Note that this traverses the UIA (accessibility) hierarchy.
108 109 110 111 |
# File 'lib/calabash-cucumber/uia.rb', line 108 def uia_names(*queryparts) #TODO escape '\n etc in query uia_handle_command(:names, queryparts) end |
#uia_query(*queryparts) ⇒ Array<Hash>
Invoke a Calabash query inside the UIAutomation Calabash engine Note that this traverses the UIA (accessibility) hierarchy.
65 66 67 68 |
# File 'lib/calabash-cucumber/uia.rb', line 65 def uia_query(*queryparts) #TODO escape '\n etc in query uia_handle_command(:query, queryparts) end |
#uia_query_windows(*queryparts) ⇒ Array<Hash>
Invoke a Calabash query inside the UIAutomation Calabash engine - includes all UIAWindows. Note that this traverses the UIA (accessibility) hierarchy.
82 83 84 85 |
# File 'lib/calabash-cucumber/uia.rb', line 82 def uia_query_windows(*queryparts) #TODO escape '\n etc in query uia_handle_command(:queryWindows, queryparts) end |