@@ -86,6 +86,7 @@ public class AppiumDriver extends RemoteWebDriver implements
86
86
private final Set <String > absentExtensionNames = new HashSet <>();
87
87
protected URI biDiUri ;
88
88
protected BiDi biDi ;
89
+ private boolean wasBiDiRequested = false ;
89
90
90
91
/**
91
92
* Creates a new instance based on command {@code executor} and {@code capabilities}.
@@ -275,12 +276,14 @@ public Optional<BiDi> maybeGetBiDi() {
275
276
@ Nonnull
276
277
public BiDi getBiDi () {
277
278
var webSocketUrl = ((BaseOptions <?>) this .capabilities ).getWebSocketUrl ().orElseThrow (
278
- () -> new BiDiException (
279
- String .format (
280
- "BiDi is not enabled for this driver session. "
281
- + "Did you set %s to true?" , SupportsWebSocketUrlOption .WEB_SOCKET_URL
282
- )
283
- )
279
+ () -> {
280
+ var suffix = wasBiDiRequested
281
+ ? "Do both the server and the driver declare BiDi support?"
282
+ : String .format ("Did you set %s to true?" , SupportsWebSocketUrlOption .WEB_SOCKET_URL );
283
+ return new BiDiException (String .format (
284
+ "BiDi is not enabled for this driver session. %s" , suffix
285
+ ));
286
+ }
284
287
);
285
288
if (this .biDiUri == null ) {
286
289
throw new BiDiException (
@@ -332,7 +335,10 @@ && isNullOrEmpty((String) rawResponseCapabilities.get(CapabilityType.BROWSER_NAM
332
335
rawResponseCapabilities .remove (CapabilityType .BROWSER_NAME );
333
336
}
334
337
this .capabilities = new BaseOptions <>(rawResponseCapabilities );
335
- if (Boolean .TRUE .equals (requestCapabilities .getCapability (SupportsWebSocketUrlOption .WEB_SOCKET_URL ))) {
338
+ this .wasBiDiRequested = Boolean .TRUE .equals (
339
+ requestCapabilities .getCapability (SupportsWebSocketUrlOption .WEB_SOCKET_URL )
340
+ );
341
+ if (wasBiDiRequested ) {
336
342
this .initBiDi ((BaseOptions <?>) capabilities );
337
343
}
338
344
setSessionId (response .getSessionId ());
0 commit comments