From 2c0da5ad164dcc125e5c1f52a5def80ca0fc57f3 Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Wed, 28 Feb 2024 12:50:43 +0300 Subject: [PATCH] Added se:cdpVersion to returned capabilities (related to #1405) --- selenoid.go | 8 +++++++- selenoid_test.go | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/selenoid.go b/selenoid.go index 96e50843..439e2244 100644 --- a/selenoid.go +++ b/selenoid.go @@ -9,7 +9,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/aerokube/selenoid/info" "io" "log" "net" @@ -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" @@ -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 + } + } } } } diff --git a/selenoid_test.go b/selenoid_test.go index ee09ece2..b6f568d0 100644 --- a/selenoid_test.go +++ b/selenoid_test.go @@ -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") } @@ -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)