From 41dfb46462bf25f329c56032dbfdfece39eafef6 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Mon, 20 Sep 2021 18:49:21 +0530 Subject: [PATCH] [js] Add a check for Grid CDP endpoint --- javascript/node/selenium-webdriver/lib/webdriver.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/javascript/node/selenium-webdriver/lib/webdriver.js b/javascript/node/selenium-webdriver/lib/webdriver.js index 007392e7c2b29..fd78d2ac609f5 100644 --- a/javascript/node/selenium-webdriver/lib/webdriver.js +++ b/javascript/node/selenium-webdriver/lib/webdriver.js @@ -1229,6 +1229,19 @@ class WebDriver { if (target && cdpTargets.indexOf(target.toLowerCase()) === -1) { throw new error.InvalidArgumentError('invalid target value') } + + if (debuggerAddress.match(/\/se\/cdp/)) { + if (debuggerAddress.match("ws:\/\/", "http:\/\/")) { + return debuggerAddress.replace("ws:\/\/", "http:\/\/") + } + else if (debuggerAddress.match("wss:\/\/", "https:\/\/")) { + return debuggerAddress.replace("wss:\/\/", "https:\/\/") + } + else { + return debuggerAddress + } + } + const path = '/json/version' let request = new http.Request('GET', path) let client = new http.HttpClient('http://' + debuggerAddress)