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.
@@ -1101,7 +1101,21 @@ public String toString() {
if (caps == null) {
return super.toString();
}
- return String.format("%s: %s on %s (%s)", getClass().getSimpleName(),
- caps.getBrowserName(), caps.getPlatform(), getSessionId());
+
+ // w3c name first
+ Object platform = caps.getCapability("platformName");
+ if (!(platform instanceof String)) {
+ platform = caps.getCapability("platform");
+ }
+ if (platform == null) {
+ platform = "unknown";
+ }
+
+ return String.format(
+ "%s: %s on %s (%s)",
+ getClass().getSimpleName(),
+ caps.getBrowserName(),
+ platform,
+ getSessionId());
}
}
