Skip to content

Commit

Permalink
Added se:cdpVersion to returned capabilities (related to aerokube#1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
vania-pooh committed Feb 28, 2024
1 parent 7c379b7 commit 2c0da5a
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 2c0da5a

Please sign in to comment.