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..ffdd66dfc286d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "selenium", + "name": "npm-proj-1701450820747-0.5973624904752477G6pJwj", "lockfileVersion": 2, "requires": true, "packages": { @@ -12,7 +12,7 @@ "@mui/material": "^5.14.14", "@novnc/novnc": "^1.4.0", "@types/react": "^18.2.31", - "@types/react-dom": "^18.2.7", + "@types/react-dom": "^18.2.15", "@types/react-modal": "^3.16.0", "@types/react-router-dom": "^5.3.3", "graphql": "^16.7.1", @@ -4877,9 +4877,9 @@ } }, "node_modules/@types/react-dom": { - "version": "18.2.7", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.7.tgz", - "integrity": "sha512-GRaAEriuT4zp9N4p1i8BDBYmEyfo+xQ3yHjJU4eiK5NDa1RmUZG+unZABUTK4/Ox/M+GaHwb6Ow8rUITrtjszA==", + "version": "18.2.15", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.15.tgz", + "integrity": "sha512-HWMdW+7r7MR5+PZqJF6YFNSCtjz1T0dsvo/f1BV6HkV+6erD/nA7wd9NM00KVG83zf2nJ7uATPO9ttdIPvi3gg==", "dependencies": { "@types/react": "*" } @@ -26700,9 +26700,9 @@ } }, "@types/react-dom": { - "version": "18.2.7", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.7.tgz", - "integrity": "sha512-GRaAEriuT4zp9N4p1i8BDBYmEyfo+xQ3yHjJU4eiK5NDa1RmUZG+unZABUTK4/Ox/M+GaHwb6Ow8rUITrtjszA==", + "version": "18.2.15", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.15.tgz", + "integrity": "sha512-HWMdW+7r7MR5+PZqJF6YFNSCtjz1T0dsvo/f1BV6HkV+6erD/nA7wd9NM00KVG83zf2nJ7uATPO9ttdIPvi3gg==", "requires": { "@types/react": "*" } diff --git a/package.json b/package.json index f27d961493679..b013986b1ab64 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@mui/material": "^5.14.14", "@novnc/novnc": "^1.4.0", "@types/react": "^18.2.31", - "@types/react-dom": "^18.2.7", + "@types/react-dom": "^18.2.15", "@types/react-modal": "^3.16.0", "@types/react-router-dom": "^5.3.3", "graphql": "^16.7.1",