diff --git a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java index 4c11c15209ca3..9f9e2a3ab6ad9 100644 --- a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java @@ -838,6 +838,9 @@ private Session createExternalSession( private URI rewrite(String path) { try { String scheme = "https".equals(gridUri.getScheme()) ? "wss" : "ws"; + if (gridUri.getPath() != null && !gridUri.getPath().isEmpty()) { + path = gridUri.getPath() + path; + } return new URI( scheme, gridUri.getUserInfo(), gridUri.getHost(), gridUri.getPort(), path, null, null); } catch (URISyntaxException e) { diff --git a/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java b/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java index 9ee8b8dca7f54..6c36e67863d7d 100644 --- a/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java +++ b/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java @@ -279,6 +279,40 @@ void nodeDrainsAfterSessionCountIsReached() throws URISyntaxException { assertThat(localNode.isDraining()).isTrue(); } + @Test + void seVncCdpUrlCapabilityWhenGridUrlWithSubPath() throws URISyntaxException { + Tracer tracer = DefaultTestTracer.createTracer(); + EventBus bus = new GuavaEventBus(); + String gridUrl = "http://localhost:7890/subPath"; + URI uri = new URI(gridUrl); + Capabilities stereotype = new ImmutableCapabilities("se:vncLocalAddress", "ws://localhost:7900", + "se:cdp", "ws://localhost:9222/devtools/browser/1a2b3c4d5e6f"); + + LocalNode.Builder builder = + LocalNode.builder(tracer, bus, uri, uri, registrationSecret) + .enableCdp(true) + .add( + stereotype, + new TestSessionFactory( + (id, caps) -> new Session(id, uri, stereotype, caps, Instant.now()))); + LocalNode localNode = builder.build(); + + Either response = + localNode.newSession( + new CreateSessionRequest(ImmutableSet.of(W3C), stereotype, ImmutableMap.of())); + assertThat(response.isRight()).isTrue(); + + CreateSessionResponse sessionResponse = response.right(); + Capabilities capabilities = sessionResponse.getSession().getCapabilities(); + Object seVnc = capabilities.getCapability("se:vnc"); + assertThat(seVnc).isNotNull(); + assertThat(seVnc.toString().contains(gridUrl.replace("http", "ws"))).isTrue(); + + Object seCdp = capabilities.getCapability("se:cdp"); + assertThat(seCdp).isNotNull(); + assertThat(seCdp.toString().contains(gridUrl.replace("http", "ws"))).isTrue(); + } + @Test void cdpIsDisabledAndResponseCapsShowThat() throws URISyntaxException { Tracer tracer = DefaultTestTracer.createTracer(); diff --git a/package-lock.json b/package-lock.json index 882abf2270a53..4b1dbc10b8b29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "selenium", + "name": "npm-proj-1701450826169-0.59403090301774695exteh", "lockfileVersion": 2, "requires": true, "packages": { @@ -11,7 +11,7 @@ "@mui/icons-material": "^5.14.14", "@mui/material": "^5.14.14", "@novnc/novnc": "^1.4.0", - "@types/react": "^18.2.31", + "@types/react": "^18.2.37", "@types/react-dom": "^18.2.7", "@types/react-modal": "^3.16.0", "@types/react-router-dom": "^5.3.3", @@ -4867,9 +4867,9 @@ "dev": true }, "node_modules/@types/react": { - "version": "18.2.31", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.31.tgz", - "integrity": "sha512-c2UnPv548q+5DFh03y8lEDeMfDwBn9G3dRwfkrxQMo/dOtRHUUO57k6pHvBIfH/VF4Nh+98mZ5aaSe+2echD5g==", + "version": "18.2.37", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.37.tgz", + "integrity": "sha512-RGAYMi2bhRgEXT3f4B92WTohopH6bIXw05FuGlmJEnv/omEn190+QYEIYxIAuIBdKgboYYdVved2p1AxZVQnaw==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -26690,9 +26690,9 @@ "dev": true }, "@types/react": { - "version": "18.2.31", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.31.tgz", - "integrity": "sha512-c2UnPv548q+5DFh03y8lEDeMfDwBn9G3dRwfkrxQMo/dOtRHUUO57k6pHvBIfH/VF4Nh+98mZ5aaSe+2echD5g==", + "version": "18.2.37", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.37.tgz", + "integrity": "sha512-RGAYMi2bhRgEXT3f4B92WTohopH6bIXw05FuGlmJEnv/omEn190+QYEIYxIAuIBdKgboYYdVved2p1AxZVQnaw==", "requires": { "@types/prop-types": "*", "@types/scheduler": "*", diff --git a/package.json b/package.json index f27d961493679..d13f9ff5a9ee1 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@mui/icons-material": "^5.14.14", "@mui/material": "^5.14.14", "@novnc/novnc": "^1.4.0", - "@types/react": "^18.2.31", + "@types/react": "^18.2.37", "@types/react-dom": "^18.2.7", "@types/react-modal": "^3.16.0", "@types/react-router-dom": "^5.3.3",