Skip to content

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 bad7973
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,17 @@ 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 response from older browsers (chrome < 75)
if body["sessionId"] != nil {
sessionId = body["sessionId"].(string)
} 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 bad7973

Please sign in to comment.