lib/calabash-android/operations.rb in calabash-android-0.3.2.pre3 vs lib/calabash-android/operations.rb in calabash-android-0.3.2.pre4

- old
+ new

@@ -242,16 +242,28 @@ name = name.split(".png")[0] end end @@screenshot_count ||= 0 - res = http("/screenshot") - path = "#{prefix}#{name}_#{@@screenshot_count}.png" - File.open(path, 'wb') do |f| - f.write res + + if ENV["SCREENSHOT_VIA_USB"] == "true" + screenshot_cmd = "java -jar #{File.join(File.dirname(__FILE__), 'lib', 'screenShotTaker.jar')} #{path}" + log screenshot_cmd + raise "Could not take screenshot" unless system(screenshot_cmd) + else + begin + res = http("/screenshot") + rescue EOFError + raise "Could not take screenshot. App is most likely not running anymore." + end + File.open(path, 'wb') do |f| + f.write res + end end + + @@screenshot_count += 1 path end def adb_command @@ -302,10 +314,14 @@ raise msg end end def shutdown_test_server - http("/kill") + begin + http("/kill") + rescue EOFError + log ("Could not kill app. App is most likely not running anymore.") + end end ##location def set_gps_coordinates_from_location(location) require 'geocoder'