lib/appium_lib/driver.rb in appium_lib-0.6.5 vs lib/appium_lib/driver.rb in appium_lib-0.6.6

- old
+ new

@@ -191,11 +191,12 @@ class Driver @@loaded = false attr_reader :default_wait, :app_path, :app_name, :device, :app_package, :app_activity, :app_wait_activity, - :sauce_username, :sauce_access_key, :port, :debug + :sauce_username, :sauce_access_key, :port, :debug, + :export_session # The amount to sleep in seconds before every webdriver http call. attr_accessor :global_webdriver_http_sleep # Creates a new driver. # :device is :android, :ios, or :selendroid @@ -231,10 +232,12 @@ $driver.driver_quit if $driver opts = {} if opts.nil? # convert to downcased symbols opts.each_pair { |k,v| opts[k.to_s.downcase.strip.intern] = v } + @export_session = opts.fetch :export_session, false + @default_wait = opts.fetch :wait, 30 # Path to the .apk, .app or .app.zip. # The path can be local or remote for Sauce. @app_path = opts.fetch :app_path, ENV['APP_PATH'] @@ -407,13 +410,14 @@ # Takes a png screenshot and saves to the target path. # # Example: screenshot '/tmp/hi.png' # # @param png_save_path [String] the full path to save the png - # @return [void] + # @return [nil] def screenshot png_save_path @driver.save_screenshot png_save_path + nil end # Quits the driver # @return [void] def driver_quit @@ -430,10 +434,20 @@ begin @driver = Selenium::WebDriver.for :remote, http_client: @client, desired_capabilities: capabilities, url: server_url # Load touch methods. Required for Selendroid. @driver.extend Selenium::WebDriver::DriverExtensions::HasTouchScreen + + # export session + if @export_session + begin + File.open('/tmp/appium_lib_session', 'w') do |f| + f.puts @driver.session_id + end + rescue + end + end rescue Errno::ECONNREFUSED raise 'ERROR: Unable to connect to Appium. Is the server running?' end # Set timeout to a large number so that Appium doesn't quit @@ -550,6 +564,6 @@ end # end module Appium # Paging in Pry is annoying :q required to exit. # With pager disabled, the output is similar to IRB # Only set if Pry is defined. -Pry.config.pager = false if defined?(Pry) +Pry.config.pager = false if defined?(Pry) \ No newline at end of file