@@ -223,4 +223,67 @@ void remoteResponseOverridesStereotypeSePrefixedCaps() {
223223 // Remote response value should win over stereotype (merge overlays remote on top)
224224 assertThat (sessionCaps .getCapability ("se:downloadsEnabled" )).isEqualTo (false );
225225 }
226+
227+ @ Test
228+ void requestedAppiumApplicationWinsOverBrowserName () {
229+ String fakeSessionId = UUID .randomUUID ().toString ();
230+
231+ // Remote returns its own se:downloadsEnabled value
232+ Map <String , Object > responsePayload =
233+ Map .of (
234+ "value" ,
235+ Map .of (
236+ "sessionId" ,
237+ fakeSessionId ,
238+ "capabilities" ,
239+ Map .of ("platformName" , "android" , "se:downloadsEnabled" , false )));
240+
241+ Route route =
242+ Route .post ("/session" )
243+ .to (
244+ () ->
245+ req -> {
246+ HttpResponse response = new HttpResponse ();
247+ response .setStatus (200 );
248+ response .setContent (Contents .asJson (responsePayload ));
249+ return response ;
250+ });
251+
252+ PassthroughHttpClient .Factory clientFactory = new PassthroughHttpClient .Factory (route );
253+ Tracer tracer = DefaultTestTracer .createTracer ();
254+
255+ Capabilities stereotype =
256+ new ImmutableCapabilities (
257+ "browserName" , "chrome" ,
258+ "platformName" , "android" ,
259+ "se:downloadsEnabled" , true );
260+
261+ RelaySessionFactory factory =
262+ new RelaySessionFactory (
263+ tracer ,
264+ clientFactory ,
265+ Duration .ofSeconds (300 ),
266+ URI .create ("http://localhost:4723" ),
267+ null ,
268+ "" ,
269+ stereotype );
270+
271+ Capabilities requestCaps =
272+ new ImmutableCapabilities (
273+ "appium:app" , "http://localhost/app.apk" ,
274+ "platformName" , "android" );
275+
276+ CreateSessionRequest sessionRequest =
277+ new CreateSessionRequest (Set .of (Dialect .W3C ), requestCaps , Map .of ());
278+
279+ Either <WebDriverException , ActiveSession > result = factory .apply (sessionRequest );
280+
281+ assertThat (result .isRight ()).isTrue ();
282+ ActiveSession session = result .right ();
283+ Capabilities sessionCaps = session .getCapabilities ();
284+
285+ // Remote response value should win over stereotype (merge overlays remote on top)
286+ assertThat (sessionCaps .getCapability ("appium:app" )).isEqualTo ("http://localhost/app.apk" );
287+ assertThat (sessionCaps .getCapability ("browserName" )).isEqualTo (null );
288+ }
226289}
0 commit comments