From 68dd34ea7d1fc74872b1f01300e823c6c2b49936 Mon Sep 17 00:00:00 2001 From: DudaGod Date: Thu, 13 Jul 2023 11:39:27 +0300 Subject: [PATCH] fix: correctly parse sessionId for chrome less 75 --- selenoid.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/selenoid.go b/selenoid.go index 1f9a2ee2..1987d387 100644 --- a/selenoid.go +++ b/selenoid.go @@ -413,12 +413,19 @@ func processBody(input []byte, host string) ([]byte, string, error) { if err != nil { return nil, sessionId, fmt.Errorf("parse body response: %v", err) } - if raw, ok := body["value"]; ok { - if v, ok := raw.(map[string]interface{}); ok { - if raw, ok := v["capabilities"]; ok { - if c, ok := raw.(map[string]interface{}); ok { - sessionId = v["sessionId"].(string) - c["se:cdp"] = fmt.Sprintf("ws://%s/devtools/%s/", host, sessionId) + // handle jsonwp response from older browsers (chrome < 75) + if rawId, ok := body["sessionId"]; ok { + if si, ok := rawId.(string); ok { + sessionId = si + } + } else { + if raw, ok := body["value"]; ok { + if v, ok := raw.(map[string]interface{}); ok { + if raw, ok := v["capabilities"]; ok { + if c, ok := raw.(map[string]interface{}); ok { + sessionId = v["sessionId"].(string) + c["se:cdp"] = fmt.Sprintf("ws://%s/devtools/%s/", host, sessionId) + } } } }