Skip to content

Commit c3999f9

Browse files
authored
use :app without modifications (#110)
* use :app without modifications * update changelog * tweak
1 parent 63db671 commit c3999f9

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
55
### Enhancements
6+
- Relax the logic of `:app` capability
67

78
### Bug fixes
89

lib/appium_lib_core/driver.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,19 @@ def get_appium_lib_opts(opts)
387387

388388
# @private
389389
# Path to the .apk, .app or .app.zip.
390-
# The path can be local or remote for Sauce.
390+
# The path can be local, HTTP/S, Windows Share and other path like `sauce-storage:`.
391+
# Use @caps[:app] without modifications if the path isn't HTTP/S or local path.
391392
def set_app_path
392393
return unless @caps && @caps[:app] && !@caps[:app].empty?
393394
return if @caps[:app] =~ URI::DEFAULT_PARSER.make_regexp
394395

395-
@caps[:app] = File.expand_path(@caps[:app])
396+
app_path = File.expand_path(@caps[:app])
397+
@caps[:app] = if File.exist? app_path
398+
app_path
399+
else
400+
::Appium::Logger.info("Use #{@caps[:app]} directly")
401+
@caps[:app]
402+
end
396403
end
397404

398405
# @private

test/unit/common_test.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ def test_create_session_force_mjsonwp_false
8181
driver
8282
end
8383

84-
def test_create_session_force_mjsonwp_with_http_package
84+
def test_create_session_force_mjsonwp_with_source_package
8585
response = {
8686
status: 0, # To make bridge.dialect == :oss
8787
value: {
8888
sessionId: '1234567890',
8989
capabilities: {
9090
platformName: :android,
9191
automationName: 'uiautomator2',
92-
app: 'test/functional/app/api.apk',
92+
app: 'sauce-storage:test/functional/app/api.apk',
9393
platformVersion: '7.1.1',
9494
deviceName: 'Android Emulator',
9595
appPackage: 'io.appium.android.apis'
@@ -99,7 +99,7 @@ def test_create_session_force_mjsonwp_with_http_package
9999
http_caps = {
100100
platformName: :android,
101101
automationName: 'uiautomator2',
102-
app: 'http://example.com/test.apk.zip',
102+
app: 'sauce-storage:test/functional/app/api.apk',
103103
platformVersion: '7.1.1',
104104
deviceName: 'Android Emulator',
105105
appPackage: 'io.appium.android.apis'
@@ -119,7 +119,7 @@ def test_create_session_force_mjsonwp_with_http_package
119119
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
120120
assert_requested(:post, "#{Mock::SESSION}/timeouts/implicit_wait", body: { ms: 20_000 }.to_json, times: 1)
121121

122-
assert_equal 'http://example.com/test.apk.zip', core.caps[:app]
122+
assert_equal 'sauce-storage:test/functional/app/api.apk', core.caps[:app]
123123
end
124124

125125
def test_create_session_w3c

0 commit comments

Comments
 (0)