Skip to content

Commit a724d5d

Browse files
Fix #224
1 parent d05bfe8 commit a724d5d

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lib/appium_lib/driver.rb

+19-7
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def self.load_appium_txt opts={}
9494
data = Appium::symbolize_keys data
9595
ap data unless data.empty? if verbose
9696

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
9999
end
100100

101101
# return list of require files as an array
@@ -266,8 +266,8 @@ def initialize opts={}
266266

267267
# Path to the .apk, .app or .app.zip.
268268
# 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
271271
end
272272

273273
# https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile
@@ -358,12 +358,24 @@ def appium_server_version
358358
end
359359

360360
# 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+
#
361367
# @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?
364376
# may be absolute path to file on remote server.
365377
# 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
367379
# Sauce storage API. http://saucelabs.com/docs/rest#storage
368380
return app_path if app_path.start_with? 'sauce-storage:'
369381
return app_path if app_path.match(/^http/) # public URL for Sauce

0 commit comments

Comments
 (0)