Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
fix: correctly parse sessionId for chrome less 75
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Jul 13, 2023
1 parent f0f19ce commit 68dd34e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit 68dd34e

Please sign in to comment.