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

Commit

Permalink
Added se:cdpVersion to returned capabilities (related to #1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
vania-pooh committed Feb 28, 2024
1 parent fd32287 commit 61491c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/aerokube/selenoid/info"
"io"
"log"
"net"
Expand All @@ -24,6 +23,8 @@ import (
"sync"
"time"

"github.com/aerokube/selenoid/info"

"github.com/aerokube/selenoid/event"
"github.com/aerokube/selenoid/jsonerror"
"github.com/aerokube/selenoid/service"
Expand Down Expand Up @@ -427,6 +428,11 @@ func processBody(input []byte, host string) ([]byte, string, error) {
if c, ok := raw.(map[string]interface{}); ok {
sessionId = v["sessionId"].(string)
c["se:cdp"] = fmt.Sprintf("ws://%s/devtools/%s/", host, sessionId)
if rbv, ok := c["browserVersion"]; ok {
if bv, ok := rbv.(string); ok {
c["se:cdpVersion"] = bv
}
}
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion selenoid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ func TestAddedSeCdpCapability(t *testing.T) {
fn := func(input map[string]interface{}) {
input["value"] = map[string]interface{}{
"sessionId": input["sessionId"],
"capabilities": make(map[string]interface{}),
"capabilities": map[string]interface{}{"browserVersion": "some-version"},
}
delete(input, "sessionId")
}
Expand All @@ -958,6 +958,11 @@ func TestAddedSeCdpCapability(t *testing.T) {
assert.True(t, ok)
capabilities, ok := rc.(map[string]interface{})
assert.True(t, ok)
rcv, ok := capabilities["se:cdpVersion"]
assert.True(t, ok)
cv, ok := rcv.(string)
assert.True(t, ok)
assert.NotEmpty(t, cv)
rws, ok := capabilities["se:cdp"]
assert.True(t, ok)
ws, ok := rws.(string)
Expand Down

0 comments on commit 61491c4

Please sign in to comment.