Is there a way to utilize usingSession() in Webdriver js? I already have a webdriver session set up by another process and I want to connect to that session using the webdriver js API.
Updated:
I found a solution to connect to an existing session in Webdriver Js by taking advantage of inner APIs:
function createDriver(port, session){
var base = require('selenium-webdriver/_base'),
executors = require('selenium-webdriver/executors');
var url = base_url+':'+port;
var WebDriver = base.require('webdriver.WebDriver');
var executor = executors.createExecutor(url);
return WebDriver.attachToSession(executor, session);
}
Unfortunately, it seems that you can't simply attach to an existing session if you use the "builder.js" at root level (node_modules\selenium-webdriver) which is the default when initializing like this:
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
The builder.js at the mentioned root level only allows you to import webdriver.Builder, which lacks advanced functionalities. For more options, you would need to use the builder.js located in (node_modules\selenium-webdriver\lib\webdriver\builder.js), providing more capabilities such as attaching easily to an existing session.