@@ -94,8 +94,8 @@ def self.load_appium_txt opts={}
94
94
data = Appium ::symbolize_keys data
95
95
ap data unless data . empty? if verbose
96
96
97
- if data && data [ :caps ] && data [ :caps ] [ :app ]
98
- data [ :caps ] [ :app ] = Appium ::Driver . absolute_app_path data [ :caps ] [ :app ]
97
+ if data && data [ :caps ] && data [ :caps ] [ :app ] && ! data [ :caps ] [ :app ] . empty?
98
+ data [ :caps ] [ :app ] = Appium ::Driver . absolute_app_path data
99
99
end
100
100
101
101
# return list of require files as an array
@@ -266,8 +266,8 @@ def initialize opts={}
266
266
267
267
# Path to the .apk, .app or .app.zip.
268
268
# The path can be local or remote for Sauce.
269
- unless ! @caps || @caps [ :app ] . nil? || @caps [ :app ] . empty?
270
- @caps [ :app ] = self . class . absolute_app_path @caps [ :app ]
269
+ if @caps && @caps [ :app ] && ! @caps [ :app ] . empty?
270
+ @caps [ :app ] = self . class . absolute_app_path opts
271
271
end
272
272
273
273
# https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile
@@ -358,12 +358,24 @@ def appium_server_version
358
358
end
359
359
360
360
# Converts app_path to an absolute path.
361
+ #
362
+ # opts is the full options hash (caps and appium_lib). If server_url is set
363
+ # then the app path is used as is.
364
+ #
365
+ # if app isn't set then an error is raised.
366
+ #
361
367
# @return [String] APP_PATH as an absolute path
362
- def self . absolute_app_path app_path
363
- raise 'APP_PATH not set!' if app_path . nil? || app_path . empty?
368
+ def self . absolute_app_path opts
369
+ raise 'opts must be a hash' unless opts . is_a? Hash
370
+ caps = opts [ :caps ] || { }
371
+ appium_lib_opts = opts [ :appium_lib ] || { }
372
+ server_url = appium_lib_opts . fetch :server_url , false
373
+
374
+ app_path = caps [ :app ]
375
+ raise 'absolute_app_path invoked and app is not set!' if app_path . nil? || app_path . empty?
364
376
# may be absolute path to file on remote server.
365
377
# if the file is on the remote server then we can't check if it exists
366
- return app_path if @custom_url
378
+ return app_path if server_url
367
379
# Sauce storage API. http://saucelabs.com/docs/rest#storage
368
380
return app_path if app_path . start_with? 'sauce-storage:'
369
381
return app_path if app_path . match ( /^http/ ) # public URL for Sauce
0 commit comments