How to get session ID of a running test via script in NightwatchJS?
Hello Ian,
To get session ID of a running test via script in NightwatchJS, use the below code snippet:
module.exports = {
"Demo test Google" : function (browser) {
browser.session(function(session) {
console.log(session.sessionId);
});
browser
.url("http://www.google.com")
.waitForElementVisible('body', 1000)
.setValue('input[type=text]', 'nightwatch')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#main', 'The Night Watch')
.end();
}
};
Ref: Getting the sessionId of a session running in nightwatch · GitHub