Skip to content

Commit bd255ec

Browse files
committed
Avoid throwing an exception in RemoteWebDriver.toString()
There's no guarantee we'll know the remote platform and be able to construct a `Platform` instance from it.
1 parent 1080c91 commit bd255ec

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

java/client/src/org/openqa/selenium/remote/RemoteWebDriver.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,21 @@ public String toString() {
11011101
if (caps == null) {
11021102
return super.toString();
11031103
}
1104-
return String.format("%s: %s on %s (%s)", getClass().getSimpleName(),
1105-
caps.getBrowserName(), caps.getPlatform(), getSessionId());
1104+
1105+
// w3c name first
1106+
Object platform = caps.getCapability("platformName");
1107+
if (!(platform instanceof String)) {
1108+
platform = caps.getCapability("platform");
1109+
}
1110+
if (platform == null) {
1111+
platform = "unknown";
1112+
}
1113+
1114+
return String.format(
1115+
"%s: %s on %s (%s)",
1116+
getClass().getSimpleName(),
1117+
caps.getBrowserName(),
1118+
platform,
1119+
getSessionId());
11061120
}
11071121
}

0 commit comments

Comments
 (0)