When I'm using Node.js along with the selenium-webdriver
package for running my tests, a new session is started and a new window opens each time a test begins. I've been attempting to retrieve the session Id and make use of it later by calling getSession()
(reference link )
var webdriver = require('selenium-webdriver');
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
var server = new SeleniumServer('./seleniumServer/selenium-server-standalone-2.43.1.jar', {
port: 4444
});
server.start();
var driver = new webdriver.Builder()
.usingServer(server.address())
.withCapabilities(webdriver.Capabilities.firefox())
.build();
console.log(driver.getSession());
However, this is resulting in an exception being thrown:
getSession();
^
TypeError: Object [object Object] has no method 'getSession'
at Object.<anonymous> (\testing\demo_1.js:14:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Could someone please help me identify what's causing the issue and guide me on how to obtain and set the selenium session id?
Furthermore, I am eager to learn how to utilize the sessionId
for connecting to an existing browser session.