lib/appium_lib/driver.rb in appium_lib-0.19.0 vs lib/appium_lib/driver.rb in appium_lib-0.19.1
- old
+ new
@@ -66,10 +66,13 @@
update data, 'APP_PATH', 'APP_APK', 'APP_PACKAGE',
'APP_ACTIVITY', 'APP_WAIT_ACTIVITY',
'DEVICE'
+ # ensure app path is resolved correctly from the context of the .txt file
+ ENV['APP_PATH'] = Appium::Driver.absolute_app_path ENV['APP_PATH']
+
# device is not case sensitive
ENV['DEVICE'] = ENV['DEVICE'].strip.downcase if !ENV['DEVICE'].nil?
if ! %w(ios android selendroid).include? ENV['DEVICE']
raise %(DEVICE="#{ENV['DEVICE']}" must be ios, android,
or selendroid.)
@@ -278,10 +281,14 @@
@app_activity = opts.fetch :app_activity, ENV['APP_ACTIVITY']
# Android app waiting activity
@app_wait_activity = opts.fetch :app_wait_activity, ENV['APP_WAIT_ACTIVITY']
+ @android_coverage = opts.fetch :android_coverage, ENV['ANDROID_COVERAGE']
+ # init to empty hash because it's merged later as an optional desired cap.
+ @android_coverage = @android_coverage ? { androidCoverage: @android_coverage} : {}
+
# Sauce Username
@sauce_username = opts.fetch :sauce_username, ENV['SAUCE_USERNAME']
# Sauce Key
@sauce_access_key = opts.fetch :sauce_access_key, ENV['SAUCE_ACCESS_KEY']
@@ -394,11 +401,11 @@
name: @app_name || 'Ruby Console Android Appium',
:'app-package' => @app_package,
:'app-activity' => @app_activity,
:'app-wait-activity' => @app_wait_activity || @app_activity,
fastClear: @fast_clear
- }
+ }.merge(@android_coverage)
end
# @private
# WebDriver capabilities. Must be valid for Sauce to work.
def ios_capabilities
@@ -412,31 +419,35 @@
end
# @private
def capabilities
caps = ['iPhone Simulator', 'iPad Simulator'].include?(@device) ? ios_capabilities : android_capabilities
- caps[:app] = absolute_app_path unless @app_path.nil? || @app_path.empty?
+ caps[:app] = self.class.absolute_app_path(@app_path) unless @app_path.nil? || @app_path.empty?
caps
end
# Converts environment variable APP_PATH to an absolute path.
# @return [String] APP_PATH as an absolute path
- def absolute_app_path
- raise 'APP_PATH not set!' if @app_path.nil? || @app_path.empty?
+ def self.absolute_app_path app_path
+ raise 'APP_PATH not set!' if app_path.nil? || app_path.empty?
# Sauce storage API. http://saucelabs.com/docs/rest#storage
- return @app_path if @app_path.start_with? 'sauce-storage:'
- return @app_path if @app_path.match(/^http/) # public URL for Sauce
- if @app_path.match(/^(\/|[a-zA-Z]:)/) # absolute file path
- raise "App doesn't exist. #{@app_path}" unless File.exist? @app_path
- return @app_path
+ return app_path if app_path.start_with? 'sauce-storage:'
+ return app_path if app_path.match(/^http/) # public URL for Sauce
+ if app_path.match(/^(\/|[a-zA-Z]:)/) # absolute file path
+ app_path = File.expand_path app_path unless File.exist? app_path
+ raise "App doesn't exist. #{app_path}" unless File.exist? app_path
+ return app_path
end
# if it doesn't contain a slash then it's a bundle id
- return @app_path unless @app_path.match(/[\/\\]/)
+ return app_path unless app_path.match(/[\/\\]/)
- file = File.join(File.dirname(__FILE__), @app_path)
- raise "App doesn't exist #{file}" unless File.exist? file
- file
+ # relative path that must be expanded.
+ # absolute_app_path is called from load_appium_txt
+ # and the txt file path is the base of the app path in that case.
+ app_path = File.expand_path app_path
+ raise "App doesn't exist #{app_path}" unless File.exist? app_path
+ app_path
end
# Get the server url for sauce or local based on env vars.
# @return [String] the server url
def server_url
\ No newline at end of file