@@ -81,6 +81,47 @@ def test_create_session_force_mjsonwp_false
81
81
driver
82
82
end
83
83
84
+ def test_create_session_force_mjsonwp_with_http_package
85
+ response = {
86
+ status : 0 , # To make bridge.dialect == :oss
87
+ value : {
88
+ sessionId : '1234567890' ,
89
+ capabilities : {
90
+ platformName : :android ,
91
+ automationName : 'uiautomator2' ,
92
+ app : 'test/functional/app/api.apk' ,
93
+ platformVersion : '7.1.1' ,
94
+ deviceName : 'Android Emulator' ,
95
+ appPackage : 'io.appium.android.apis'
96
+ }
97
+ }
98
+ } . to_json
99
+ http_caps = {
100
+ platformName : :android ,
101
+ automationName : 'uiautomator2' ,
102
+ app : 'http://example.com/test.apk.zip' ,
103
+ platformVersion : '7.1.1' ,
104
+ deviceName : 'Android Emulator' ,
105
+ appPackage : 'io.appium.android.apis'
106
+ }
107
+
108
+ stub_request ( :post , 'http://127.0.0.1:4723/wd/hub/session' )
109
+ . with ( body : { desiredCapabilities : http_caps } . to_json )
110
+ . to_return ( headers : Mock ::HEADER , status : 200 , body : response )
111
+
112
+ stub_request ( :post , "#{ Mock ::SESSION } /timeouts/implicit_wait" )
113
+ . with ( body : { ms : 20_000 } . to_json )
114
+ . to_return ( headers : Mock ::HEADER , status : 200 , body : { value : nil } . to_json )
115
+
116
+ core = ::Appium ::Core . for ( self , { caps : http_caps . merge ( { forceMjsonwp : true } ) , appium_lib : { } } )
117
+ core . start_driver
118
+
119
+ assert_requested ( :post , 'http://127.0.0.1:4723/wd/hub/session' , times : 1 )
120
+ assert_requested ( :post , "#{ Mock ::SESSION } /timeouts/implicit_wait" , body : { ms : 20_000 } . to_json , times : 1 )
121
+
122
+ assert_equal 'http://example.com/test.apk.zip' , core . caps [ :app ]
123
+ end
124
+
84
125
def test_create_session_w3c
85
126
response = { value : RESPONSE_BASE_VALUE } . to_json
86
127
@@ -100,6 +141,56 @@ def test_create_session_w3c
100
141
driver
101
142
end
102
143
144
+ def test_create_session_w3c_with_http_package
145
+ response = {
146
+ value : {
147
+ sessionId : '1234567890' ,
148
+ capabilities : {
149
+ platformName : :android ,
150
+ automationName : 'uiautomator2' ,
151
+ app : 'http://example.com/test.apk.zip' ,
152
+ platformVersion : '7.1.1' ,
153
+ deviceName : 'Android Emulator' ,
154
+ appPackage : 'io.appium.android.apis'
155
+ }
156
+ }
157
+ } . to_json
158
+ http_caps = {
159
+ platformName : :android ,
160
+ automationName : 'uiautomator2' ,
161
+ app : 'http://example.com/test.apk.zip' ,
162
+ platformVersion : '7.1.1' ,
163
+ deviceName : 'Android Emulator' ,
164
+ appPackage : 'io.appium.android.apis'
165
+ }
166
+
167
+ appium_prefix_http_caps = {
168
+ platformName : :android ,
169
+ 'appium:automationName' => 'uiautomator2' ,
170
+ 'appium:app' => 'http://example.com/test.apk.zip' ,
171
+ 'appium:platformVersion' => '7.1.1' ,
172
+ 'appium:deviceName' => 'Android Emulator' ,
173
+ 'appium:appPackage' => 'io.appium.android.apis'
174
+ }
175
+
176
+ stub_request ( :post , 'http://127.0.0.1:4723/wd/hub/session' )
177
+ . with ( body : { desiredCapabilities : http_caps ,
178
+ capabilities : { alwaysMatch : appium_prefix_http_caps , firstMatch : [ { } ] } } . to_json )
179
+ . to_return ( headers : Mock ::HEADER , status : 200 , body : response )
180
+
181
+ stub_request ( :post , "#{ Mock ::SESSION } /timeouts" )
182
+ . with ( body : { implicit : 20_000 } . to_json )
183
+ . to_return ( headers : Mock ::HEADER , status : 200 , body : { value : nil } . to_json )
184
+
185
+ core = ::Appium ::Core . for ( self , { caps : http_caps , appium_lib : { } } )
186
+ core . start_driver
187
+
188
+ assert_requested ( :post , 'http://127.0.0.1:4723/wd/hub/session' , times : 1 )
189
+ assert_requested ( :post , "#{ Mock ::SESSION } /timeouts" , body : { implicit : 20_000 } . to_json , times : 1 )
190
+
191
+ assert_equal 'http://example.com/test.apk.zip' , core . caps [ :app ]
192
+ end
193
+
103
194
def test_add_appium_prefix_compatible_with_oss
104
195
cap = {
105
196
platformName : :ios ,
0 commit comments