I'm not an expert of Selenium, so I may miss something here.
- One of the software in the corp starts a google chrome with ChromeDriver.
- I would like to attach to this browser from my JavaScript code.
I know the port where the ChromeDriver starts:
Starting ChromeDriver 77.0.3865.10 (bc3579f611bbc73331171afe020ec7a45e6ccc55-refs/branch-heads/3865@{#93}) on port 55848
I try to connect from JS:
const webdriver = require('selenium-webdriver')
void async function() {
let driver = await new webdriver.Builder().forBrowser('chrome').usingServer('http://localhost:55848/').build();
await driver.get('http://www.google.com/ncr');
await driver.findElement(By.name('q')).sendKeys('webdriver');
await driver.findElement(By.name('btnG')).click();
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
driver.quit();
}();
The connection is not successful. What I can think is that this code tries to start a new instance.
There is an error message:
SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 77
I checked that the running chrome version is 77 and the ChromeDriver is also 77. This Chrome that is started by the corp software is actually a portable version of Chrome. I have a Chrome 76 installed on my computer. What I can think is that the code I wrote tries to start a new instance of Chrome. And there the version does not match.
Any idea how I can connect to the existing one? And control it?
UPDATE:
I managed to do the same with Firefox. The Firefox is started with geckodriver. I still cannot connect it. The error message is:
SessionNotCreatedError: Session is already started
So I'm pretty sure that is not in connection with the chrome versions but it tries to create a new session instead of connecting the existing one.