Module: Calabash::Android::Operations
- Defined in:
- lib/calabash-android/operations.rb
Defined Under Namespace
Classes: Device
Instance Method Summary collapse
- #backdoor(sel, arg) ⇒ Object
- #background(secs) ⇒ Object
- #cell_swipe(options = {}) ⇒ Object
- #check_element_does_not_exist(query) ⇒ Object
- #check_element_exists(query) ⇒ Object
- #check_view_with_mark_exists(expected_mark) ⇒ Object
-
#connect_to_test_server ⇒ Object
app life cycle.
- #disconnect_from_test_server ⇒ Object
- #done ⇒ Object
- #element_exists(uiquery) ⇒ Object
-
#element_is_not_hidden(uiquery) ⇒ Object
a better name would be element_exists_and_is_not_hidden.
- #html(q) ⇒ Object
- #http(options, data = nil) ⇒ Object
- #install_app(app_path) ⇒ Object
- #interpolate(recording, options = {}) ⇒ Object
- #label(uiquery) ⇒ Object
- #load_playback_data(recording, options = {}) ⇒ Object
- #log(message) ⇒ Object
- #macro(txt) ⇒ Object
- #make_http_request(url, req) ⇒ Object
- #map(query, method_name, *method_args) ⇒ Object
- #ni ⇒ Object
- #performAction(action, *arguments) ⇒ Object
- #pinch(in_out, options = {}) ⇒ Object
- #playback(recording, options = {}) ⇒ Object
- #query(uiquery, *args) ⇒ Object
- #record_begin ⇒ Object
- #record_end(file_name) ⇒ Object
- #rotate(dir) ⇒ Object
- #screenshot ⇒ Object
- #screenshot_and_raise(msg) ⇒ Object
- #scroll(uiquery, direction) ⇒ Object
- #scroll_to_row(uiquery, number) ⇒ Object
- #set_text(uiquery, txt) ⇒ Object
- #shutdown_test_server ⇒ Object
- #start_test_server_in_background ⇒ Object
- #swipe(dir, options = {}) ⇒ Object
- #take_screenshot ⇒ Object
- #touch(uiquery, options = {}) ⇒ Object
- #uninstall_apps ⇒ Object
- #url_for(verb) ⇒ Object
- #view_with_mark_exists(expected_mark) ⇒ Object
- #wait_for(timeout, &block) ⇒ Object
Instance Method Details
#backdoor(sel, arg) ⇒ Object
394 395 396 |
# File 'lib/calabash-android/operations.rb', line 394 def backdoor(sel, arg) ni end |
#background(secs) ⇒ Object
340 341 342 |
# File 'lib/calabash-android/operations.rb', line 340 def background(secs) ni end |
#cell_swipe(options = {}) ⇒ Object
316 317 318 |
# File 'lib/calabash-android/operations.rb', line 316 def cell_swipe(={}) ni end |
#check_element_does_not_exist(query) ⇒ Object
358 359 360 361 362 |
# File 'lib/calabash-android/operations.rb', line 358 def check_element_does_not_exist( query ) if element_exists( query ) screenshot_and_raise "Expected no elements to match query: #{query}" end end |
#check_element_exists(query) ⇒ Object
352 353 354 355 356 |
# File 'lib/calabash-android/operations.rb', line 352 def check_element_exists( query ) if not element_exists( query ) screenshot_and_raise "No element found for query: #{query}" end end |
#check_view_with_mark_exists(expected_mark) ⇒ Object
364 365 366 |
# File 'lib/calabash-android/operations.rb', line 364 def check_view_with_mark_exists(expected_mark) check_element_exists( "view marked:'#{expected_mark}'" ) end |
#connect_to_test_server ⇒ Object
app life cycle
87 88 89 90 91 |
# File 'lib/calabash-android/operations.rb', line 87 def connect_to_test_server puts "Explicit calls to connect_to_test_server should be removed." puts "Please take a look in your hooks file for calls to this methods." puts "(Hooks are stored in features/support)" end |
#disconnect_from_test_server ⇒ Object
93 94 95 96 97 |
# File 'lib/calabash-android/operations.rb', line 93 def disconnect_from_test_server puts "Explicit calls to disconnect_from_test_server should be removed." puts "Please take a look in your hooks file for calls to this methods." puts "(Hooks are stored in features/support)" end |
#done ⇒ Object
320 321 322 |
# File 'lib/calabash-android/operations.rb', line 320 def done ni end |
#element_exists(uiquery) ⇒ Object
344 345 346 |
# File 'lib/calabash-android/operations.rb', line 344 def element_exists(uiquery) !query(uiquery).empty? end |
#element_is_not_hidden(uiquery) ⇒ Object
a better name would be element_exists_and_is_not_hidden
369 370 371 |
# File 'lib/calabash-android/operations.rb', line 369 def element_is_not_hidden(uiquery) ni end |
#html(q) ⇒ Object
295 296 297 |
# File 'lib/calabash-android/operations.rb', line 295 def html(q) query(q).map {|e| e['html']} end |
#http(options, data = nil) ⇒ Object
406 407 408 |
# File 'lib/calabash-android/operations.rb', line 406 def http(, data=nil) ni end |
#install_app(app_path) ⇒ Object
41 42 43 |
# File 'lib/calabash-android/operations.rb', line 41 def install_app(app_path) Device.default_device.install_app(app_path) end |
#interpolate(recording, options = {}) ⇒ Object
382 383 384 |
# File 'lib/calabash-android/operations.rb', line 382 def interpolate(recording, ={}) ni end |
#label(uiquery) ⇒ Object
281 282 283 |
# File 'lib/calabash-android/operations.rb', line 281 def label(uiquery) ni end |
#load_playback_data(recording, options = {}) ⇒ Object
374 375 376 |
# File 'lib/calabash-android/operations.rb', line 374 def load_playback_data(recording,={}) ni end |
#log(message) ⇒ Object
17 18 19 |
# File 'lib/calabash-android/operations.rb', line 17 def log() $stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{}" if (ARGV.include? "-v" or ARGV.include? "--verbose") end |
#macro(txt) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/calabash-android/operations.rb', line 25 def macro(txt) if self.respond_to?:step step(txt) else Then(txt) end end |
#make_http_request(url, req) ⇒ Object
415 416 417 |
# File 'lib/calabash-android/operations.rb', line 415 def make_http_request( url, req ) ni end |
#map(query, method_name, *method_args) ⇒ Object
402 403 404 |
# File 'lib/calabash-android/operations.rb', line 402 def map( query, method_name, *method_args ) ni end |
#ni ⇒ Object
80 81 82 |
# File 'lib/calabash-android/operations.rb', line 80 def ni raise "Not yet implemented." end |
#performAction(action, *arguments) ⇒ Object
37 38 39 |
# File 'lib/calabash-android/operations.rb', line 37 def performAction(action, *arguments) Device.default_device.perform_action(action, *arguments) end |
#pinch(in_out, options = {}) ⇒ Object
332 333 334 |
# File 'lib/calabash-android/operations.rb', line 332 def pinch(in_out,={}) ni end |
#playback(recording, options = {}) ⇒ Object
378 379 380 |
# File 'lib/calabash-android/operations.rb', line 378 def playback(recording, ={}) ni end |
#query(uiquery, *args) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/calabash-android/operations.rb', line 68 def query(uiquery, *args) raise "Currently queries are only supported for webviews" unless uiquery.start_with? "webView" uiquery.slice!(0, "webView".length) if uiquery =~ /(css|xpath):\s*(.*)/ r = performAction("query", $1, $2) JSON.parse(r["message"]) else raise "Invalid query #{uiquery}" end end |
#record_begin ⇒ Object
386 387 388 |
# File 'lib/calabash-android/operations.rb', line 386 def record_begin ni end |
#record_end(file_name) ⇒ Object
390 391 392 |
# File 'lib/calabash-android/operations.rb', line 390 def record_end(file_name) ni end |
#rotate(dir) ⇒ Object
336 337 338 |
# File 'lib/calabash-android/operations.rb', line 336 def rotate(dir) ni end |
#screenshot ⇒ Object
398 399 400 |
# File 'lib/calabash-android/operations.rb', line 398 def screenshot ni end |
#screenshot_and_raise(msg) ⇒ Object
285 286 287 288 289 |
# File 'lib/calabash-android/operations.rb', line 285 def screenshot_and_raise(msg) take_screenshot sleep 5 raise(msg) end |
#scroll(uiquery, direction) ⇒ Object
324 325 326 |
# File 'lib/calabash-android/operations.rb', line 324 def scroll(uiquery,direction) ni end |
#scroll_to_row(uiquery, number) ⇒ Object
328 329 330 |
# File 'lib/calabash-android/operations.rb', line 328 def scroll_to_row(uiquery,number) ni end |
#set_text(uiquery, txt) ⇒ Object
299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/calabash-android/operations.rb', line 299 def set_text(uiquery, txt) raise "Currently queries are only supported for webviews" unless uiquery.start_with? "webView" uiquery.slice!(0, "webView".length) if uiquery =~ /(css|xpath):\s*(.*)/ r = performAction("set_text", $1, $2, txt) JSON.parse(r["message"]) else raise "Invalid query #{uiquery}" end end |
#shutdown_test_server ⇒ Object
33 34 35 |
# File 'lib/calabash-android/operations.rb', line 33 def shutdown_test_server Device.default_device.shutdown_test_server end |
#start_test_server_in_background ⇒ Object
50 51 52 |
# File 'lib/calabash-android/operations.rb', line 50 def start_test_server_in_background Device.default_device.start_test_server_in_background() end |
#swipe(dir, options = {}) ⇒ Object
312 313 314 |
# File 'lib/calabash-android/operations.rb', line 312 def swipe(dir,={}) ni end |
#take_screenshot ⇒ Object
21 22 23 |
# File 'lib/calabash-android/operations.rb', line 21 def take_screenshot Device.default_device.take_screenshot end |
#touch(uiquery, options = {}) ⇒ Object
291 292 293 |
# File 'lib/calabash-android/operations.rb', line 291 def touch(uiquery,={}) ni end |
#uninstall_apps ⇒ Object
45 46 47 48 |
# File 'lib/calabash-android/operations.rb', line 45 def uninstall_apps Device.default_device.uninstall_app(ENV["TEST_PACKAGE_NAME"]) Device.default_device.uninstall_app(ENV["PACKAGE_NAME"]) end |
#url_for(verb) ⇒ Object
411 412 413 |
# File 'lib/calabash-android/operations.rb', line 411 def url_for( verb ) ni end |
#view_with_mark_exists(expected_mark) ⇒ Object
348 349 350 |
# File 'lib/calabash-android/operations.rb', line 348 def view_with_mark_exists(expected_mark) element_exists( "view marked:'#{expected_mark}'" ) end |
#wait_for(timeout, &block) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/calabash-android/operations.rb', line 55 def wait_for(timeout, &block) begin Timeout::timeout(timeout) do until block.call sleep 0.3 end end rescue Exception => e take_screenshot raise e end end |