Module: Calabash::Cucumber::UIA
- Included in:
- Core, IOS7Operations
- Defined in:
- lib/calabash-cucumber/uia.rb
Instance Method Summary collapse
- #escape_uia_string(string) ⇒ Object
- #send_uia_command(opts = {}) ⇒ Object
- #uia_element_does_not_exist?(*queryparts) ⇒ Boolean
- #uia_element_exists?(*queryparts) ⇒ Boolean
- #uia_enter ⇒ Object
- #uia_handle_command(cmd, *query_args) ⇒ Object
- #uia_names(*queryparts) ⇒ Object
- #uia_pan(from_q, to_q) ⇒ Object
- #uia_pan_offset(from, to, options) ⇒ Object
- #uia_pinch(*queryparts) ⇒ Object
- #uia_pinch_offset(in_or_out, offset, duration) ⇒ Object
- #uia_query(*queryparts) ⇒ Object
- #uia_screenshot(name) ⇒ Object
- #uia_scroll_to(*queryparts) ⇒ Object
- #uia_send_app_to_background(secs) ⇒ Object
- #uia_set_location(place) ⇒ Object
- #uia_swipe(*queryparts) ⇒ Object
- #uia_swipe_offset(offset, options) ⇒ Object
- #uia_tap(*queryparts) ⇒ Object
- #uia_tap_mark(mark) ⇒ Object
- #uia_tap_offset(offset) ⇒ Object
- #uia_type_string(string) ⇒ Object
Instance Method Details
#escape_uia_string(string) ⇒ Object
126 127 128 129 |
# File 'lib/calabash-cucumber/uia.rb', line 126 def escape_uia_string(string) #TODO escape '\n in query escape_quotes string end |
#send_uia_command(opts = {}) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/calabash-cucumber/uia.rb', line 8 def send_uia_command(opts ={}) launcher = @calabash_launcher || Calabash::Cucumber::Launcher.launcher_if_used run_loop = opts[:run_loop] || (launcher && launcher.active? && launcher.run_loop) command = opts[:command] raise ArgumentError, 'please supply :run_loop or instance var @calabash_launcher' unless run_loop raise ArgumentError, 'please supply :command' unless command RunLoop.send_command(run_loop, opts[:command]) end |
#uia_element_does_not_exist?(*queryparts) ⇒ Boolean
71 72 73 |
# File 'lib/calabash-cucumber/uia.rb', line 71 def uia_element_does_not_exist?(*queryparts) uia_handle_command(:elementDoesNotExist, queryparts) end |
#uia_element_exists?(*queryparts) ⇒ Boolean
67 68 69 |
# File 'lib/calabash-cucumber/uia.rb', line 67 def uia_element_exists?(*queryparts) uia_handle_command(:elementExists, queryparts) end |
#uia_enter ⇒ Object
83 84 85 |
# File 'lib/calabash-cucumber/uia.rb', line 83 def uia_enter() uia_handle_command(:enter) end |
#uia_handle_command(cmd, *query_args) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/calabash-cucumber/uia.rb', line 101 def uia_handle_command(cmd, *query_args) args = query_args.map do |part| if part.is_a?(String) "'#{escape_uia_string(part)}'" else "'#{escape_uia_string(part.to_edn)}'" end end command = %Q[uia.#{cmd}(#{args.join(', ')})] if ENV['DEBUG'] == '1' puts "Sending UIA command" puts command end s=send_uia_command :command => command if ENV['DEBUG'] == '1' puts "Result" p s end if s['status'] == 'success' s['value'] else raise s end end |
#uia_names(*queryparts) ⇒ Object
22 23 24 25 |
# File 'lib/calabash-cucumber/uia.rb', line 22 def uia_names(*queryparts) #TODO escape '\n etc in query uia_handle_command(:names, queryparts) end |
#uia_pan(from_q, to_q) ⇒ Object
39 40 41 |
# File 'lib/calabash-cucumber/uia.rb', line 39 def uia_pan(from_q, to_q) uia_handle_command(:pan, from_q, to_q) end |
#uia_pan_offset(from, to, options) ⇒ Object
43 44 45 |
# File 'lib/calabash-cucumber/uia.rb', line 43 def uia_pan_offset(from, to, ) uia_handle_command(:panOffset, from, to, ) end |
#uia_pinch(*queryparts) ⇒ Object
55 56 57 |
# File 'lib/calabash-cucumber/uia.rb', line 55 def uia_pinch(*queryparts) uia_handle_command(:pinch, queryparts) end |
#uia_pinch_offset(in_or_out, offset, duration) ⇒ Object
59 60 61 |
# File 'lib/calabash-cucumber/uia.rb', line 59 def uia_pinch_offset(in_or_out, offset, duration) uia_handle_command(:pinchOffset, in_or_out, offset, duration) end |
#uia_query(*queryparts) ⇒ Object
17 18 19 20 |
# File 'lib/calabash-cucumber/uia.rb', line 17 def uia_query(*queryparts) #TODO escape '\n etc in query uia_handle_command(:query, queryparts) end |
#uia_screenshot(name) ⇒ Object
75 76 77 |
# File 'lib/calabash-cucumber/uia.rb', line 75 def uia_screenshot(name) uia_handle_command(:elementDoesNotExist, name) end |
#uia_scroll_to(*queryparts) ⇒ Object
63 64 65 |
# File 'lib/calabash-cucumber/uia.rb', line 63 def uia_scroll_to(*queryparts) uia_handle_command(:scrollTo, queryparts) end |
#uia_send_app_to_background(secs) ⇒ Object
97 98 99 |
# File 'lib/calabash-cucumber/uia.rb', line 97 def uia_send_app_to_background(secs) uia_handle_command(:deactivate, secs) end |
#uia_set_location(place) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/calabash-cucumber/uia.rb', line 87 def uia_set_location(place) if place.is_a?(String) loc = LocationOne::Client.location_by_place(place) loc_data = {"latitude"=>loc.latitude, "longitude"=>loc.longitude} else loc_data = place end uia_handle_command(:setLocation, loc_data) end |
#uia_swipe(*queryparts) ⇒ Object
47 48 49 |
# File 'lib/calabash-cucumber/uia.rb', line 47 def uia_swipe(*queryparts) uia_handle_command(:swipe, queryparts) end |
#uia_swipe_offset(offset, options) ⇒ Object
51 52 53 |
# File 'lib/calabash-cucumber/uia.rb', line 51 def uia_swipe_offset(offset, ) uia_handle_command(:swipeOffset, offset, ) end |
#uia_tap(*queryparts) ⇒ Object
27 28 29 |
# File 'lib/calabash-cucumber/uia.rb', line 27 def uia_tap(*queryparts) uia_handle_command(:tap, queryparts) end |
#uia_tap_mark(mark) ⇒ Object
31 32 33 |
# File 'lib/calabash-cucumber/uia.rb', line 31 def uia_tap_mark(mark) uia_handle_command(:tapMark, mark) end |
#uia_tap_offset(offset) ⇒ Object
35 36 37 |
# File 'lib/calabash-cucumber/uia.rb', line 35 def uia_tap_offset(offset) uia_handle_command(:tapOffset, offset) end |
#uia_type_string(string) ⇒ Object
79 80 81 |
# File 'lib/calabash-cucumber/uia.rb', line 79 def uia_type_string(string) uia_handle_command(:typeString, string) end |