Module: Calabash::Android::Operations
- Defined in:
- lib/calabash-android/operations.rb
Defined Under Namespace
Classes: Device
Instance Method Summary collapse
- #app_to_background(secs) ⇒ Object
- #backdoor(sel, arg) ⇒ 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.
- #default_device ⇒ Object
- #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(options = {:prefix => nil, :name => nil}) ⇒ Object
- #screenshot_and_raise(msg) ⇒ Object
- #screenshot_embed(options = {:prefix => nil, :name => nil, :label => nil}) ⇒ Object
- #scroll(uiquery, direction) ⇒ Object
- #scroll_to_row(uiquery, number) ⇒ Object
- #set_gps_coordinates(latitude, longitude) ⇒ Object
- #set_gps_coordinates_from_location(location) ⇒ 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
- #wake_up ⇒ Object
Instance Method Details
#app_to_background(secs) ⇒ Object
422 423 424 |
# File 'lib/calabash-android/operations.rb', line 422 def app_to_background(secs) ni end |
#backdoor(sel, arg) ⇒ Object
476 477 478 |
# File 'lib/calabash-android/operations.rb', line 476 def backdoor(sel, arg) ni end |
#cell_swipe(options = {}) ⇒ Object
398 399 400 |
# File 'lib/calabash-android/operations.rb', line 398 def cell_swipe(={}) ni end |
#check_element_does_not_exist(query) ⇒ Object
440 441 442 443 444 |
# File 'lib/calabash-android/operations.rb', line 440 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
434 435 436 437 438 |
# File 'lib/calabash-android/operations.rb', line 434 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
446 447 448 |
# File 'lib/calabash-android/operations.rb', line 446 def check_view_with_mark_exists(expected_mark) check_element_exists( "view marked:'#{expected_mark}'" ) end |
#connect_to_test_server ⇒ Object
app life cycle
113 114 115 116 117 |
# File 'lib/calabash-android/operations.rb', line 113 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 |
#default_device ⇒ Object
32 33 34 35 36 37 |
# File 'lib/calabash-android/operations.rb', line 32 def default_device unless @default_device @default_device = Device.new(self, ENV["ADB_DEVICE_ARG"], ENV["TEST_SERVER_PORT"], ENV["APP_PATH"], ENV["TEST_APP_PATH"]) end @default_device end |
#disconnect_from_test_server ⇒ Object
119 120 121 122 123 |
# File 'lib/calabash-android/operations.rb', line 119 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
402 403 404 |
# File 'lib/calabash-android/operations.rb', line 402 def done ni end |
#element_exists(uiquery) ⇒ Object
426 427 428 |
# File 'lib/calabash-android/operations.rb', line 426 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
451 452 453 |
# File 'lib/calabash-android/operations.rb', line 451 def element_is_not_hidden(uiquery) ni end |
#html(q) ⇒ Object
377 378 379 |
# File 'lib/calabash-android/operations.rb', line 377 def html(q) query(q).map {|e| e['html']} end |
#http(options, data = nil) ⇒ Object
484 485 486 |
# File 'lib/calabash-android/operations.rb', line 484 def http(, data=nil) ni end |
#install_app(app_path) ⇒ Object
43 44 45 |
# File 'lib/calabash-android/operations.rb', line 43 def install_app(app_path) default_device.install_app(app_path) end |
#interpolate(recording, options = {}) ⇒ Object
464 465 466 |
# File 'lib/calabash-android/operations.rb', line 464 def interpolate(recording, ={}) ni end |
#label(uiquery) ⇒ Object
363 364 365 |
# File 'lib/calabash-android/operations.rb', line 363 def label(uiquery) ni end |
#load_playback_data(recording, options = {}) ⇒ Object
456 457 458 |
# File 'lib/calabash-android/operations.rb', line 456 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
493 494 495 |
# File 'lib/calabash-android/operations.rb', line 493 def make_http_request( url, req ) ni end |
#map(query, method_name, *method_args) ⇒ Object
480 481 482 |
# File 'lib/calabash-android/operations.rb', line 480 def map( query, method_name, *method_args ) ni end |
#ni ⇒ Object
106 107 108 |
# File 'lib/calabash-android/operations.rb', line 106 def ni raise "Not yet implemented." end |
#performAction(action, *arguments) ⇒ Object
39 40 41 |
# File 'lib/calabash-android/operations.rb', line 39 def performAction(action, *arguments) default_device.perform_action(action, *arguments) end |
#pinch(in_out, options = {}) ⇒ Object
414 415 416 |
# File 'lib/calabash-android/operations.rb', line 414 def pinch(in_out,={}) ni end |
#playback(recording, options = {}) ⇒ Object
460 461 462 |
# File 'lib/calabash-android/operations.rb', line 460 def playback(recording, ={}) ni end |
#query(uiquery, *args) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/calabash-android/operations.rb', line 94 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
468 469 470 |
# File 'lib/calabash-android/operations.rb', line 468 def record_begin ni end |
#record_end(file_name) ⇒ Object
472 473 474 |
# File 'lib/calabash-android/operations.rb', line 472 def record_end(file_name) ni end |
#rotate(dir) ⇒ Object
418 419 420 |
# File 'lib/calabash-android/operations.rb', line 418 def rotate(dir) ni end |
#screenshot(options = {:prefix => nil, :name => nil}) ⇒ Object
69 70 71 |
# File 'lib/calabash-android/operations.rb', line 69 def screenshot(={:prefix => nil, :name => nil}) default_device.screenshot() end |
#screenshot_and_raise(msg) ⇒ Object
367 368 369 370 371 |
# File 'lib/calabash-android/operations.rb', line 367 def screenshot_and_raise(msg) sleep 5 raise(msg) end |
#screenshot_embed(options = {:prefix => nil, :name => nil, :label => nil}) ⇒ Object
64 65 66 67 |
# File 'lib/calabash-android/operations.rb', line 64 def (={:prefix => nil, :name => nil, :label => nil}) path = default_device.screenshot() (path, "image/png", [:label] || File.basename(path)) end |
#scroll(uiquery, direction) ⇒ Object
406 407 408 |
# File 'lib/calabash-android/operations.rb', line 406 def scroll(uiquery,direction) ni end |
#scroll_to_row(uiquery, number) ⇒ Object
410 411 412 |
# File 'lib/calabash-android/operations.rb', line 410 def scroll_to_row(uiquery,number) ni end |
#set_gps_coordinates(latitude, longitude) ⇒ Object
77 78 79 |
# File 'lib/calabash-android/operations.rb', line 77 def set_gps_coordinates(latitude, longitude) default_device.set_gps_coordinates(latitude, longitude) end |
#set_gps_coordinates_from_location(location) ⇒ Object
73 74 75 |
# File 'lib/calabash-android/operations.rb', line 73 def set_gps_coordinates_from_location(location) default_device.set_gps_coordinates_from_location(location) end |
#set_text(uiquery, txt) ⇒ Object
381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/calabash-android/operations.rb', line 381 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
60 61 62 |
# File 'lib/calabash-android/operations.rb', line 60 def shutdown_test_server default_device.shutdown_test_server end |
#start_test_server_in_background ⇒ Object
56 57 58 |
# File 'lib/calabash-android/operations.rb', line 56 def start_test_server_in_background default_device.start_test_server_in_background() end |
#swipe(dir, options = {}) ⇒ Object
394 395 396 |
# File 'lib/calabash-android/operations.rb', line 394 def swipe(dir,={}) ni end |
#take_screenshot ⇒ Object
21 22 23 |
# File 'lib/calabash-android/operations.rb', line 21 def take_screenshot default_device.take_screenshot end |
#touch(uiquery, options = {}) ⇒ Object
373 374 375 |
# File 'lib/calabash-android/operations.rb', line 373 def touch(uiquery,={}) ni end |
#uninstall_apps ⇒ Object
47 48 49 50 |
# File 'lib/calabash-android/operations.rb', line 47 def uninstall_apps default_device.uninstall_app("sh.calaba.android.test") default_device.uninstall_app(ENV["PACKAGE_NAME"]) end |
#url_for(verb) ⇒ Object
489 490 491 |
# File 'lib/calabash-android/operations.rb', line 489 def url_for( verb ) ni end |
#view_with_mark_exists(expected_mark) ⇒ Object
430 431 432 |
# File 'lib/calabash-android/operations.rb', line 430 def view_with_mark_exists(expected_mark) element_exists( "view marked:'#{expected_mark}'" ) end |
#wait_for(timeout, &block) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/calabash-android/operations.rb', line 81 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 |
#wake_up ⇒ Object
52 53 54 |
# File 'lib/calabash-android/operations.rb', line 52 def wake_up default_device.wake_up() end |