Finally, it turned out that after a lot of experimentation and reading through WebDriverJS source code.
var webdriver = require('./assets/webdriver'); var driver = new webdriver.Builder(). usingServer('http://localhost:4444/wd/hub'). withCapabilities({ 'browserName': 'chrome', 'version': '', 'platform': 'ANY', 'javascriptEnabled': true }). build(); var testUrl = 'http://localhost:3000/test', hubUrl = 'http://localhost:4444/wd/hub', sessionId; driver.session_.then(function(sessionData) { sessionId = sessionData.id; driver.get(testUrl + '?wdurl=' + hubUrl + '&wdsid=' + sessionId); });
driver.session_ returns a Promise object that will contain session data and other information after the instance is created. Using .then (callback (sessionData)) will allow you to manipulate the data as you wish.
source share