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

Commit

Permalink
Merge pull request #1361 from DudaGod/fix.parse_session_id_chrome_les…
Browse files Browse the repository at this point in the history
…s_75

fix: correctly parse sessionId for chrome less 75
  • Loading branch information
vania-pooh authored Jul 14, 2023
2 parents f0f19ce + e18077a commit e83931c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ~1.20.4
go-version: ~1.20.6

- uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ~1.20.4
go-version: ~1.20.6

- uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ~1.20.4
go-version: ~1.20.6

- uses: actions/cache@v3
with:
Expand Down
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 e83931c

Please sign in to comment.