Skip to content

Commit 69bbda9

Browse files
authored
[grid] Update handling SessionId from json (#16683)
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
1 parent d4c3e1b commit 69bbda9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

java/src/org/openqa/selenium/remote/SessionId.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.openqa.selenium.remote;
1919

2020
import java.io.Serializable;
21+
import java.util.Map;
2122
import java.util.UUID;
2223
import org.jspecify.annotations.NullMarked;
2324
import org.jspecify.annotations.Nullable;
@@ -52,7 +53,7 @@ public boolean equals(@Nullable Object obj) {
5253
return obj instanceof SessionId && opaqueKey.equals(((SessionId) obj).opaqueKey);
5354
}
5455

55-
private Object toJson() {
56+
private String toJson() {
5657
return opaqueKey;
5758
}
5859

@@ -61,6 +62,13 @@ private static SessionId fromJson(Object raw) {
6162
return new SessionId(String.valueOf(raw));
6263
}
6364

65+
if (raw instanceof Map) {
66+
Map<?, ?> map = (Map<?, ?>) raw;
67+
if (map.get("value") instanceof String) {
68+
return new SessionId(String.valueOf(map.get("value")));
69+
}
70+
}
71+
6472
throw new JsonException("Unable to coerce session id from " + raw);
6573
}
6674
}

0 commit comments

Comments
 (0)