When creating my customDriver.js based on the Firefox driver defined in the selenium-cucumber-js repository mainly to set custom browser Options (headless, private, etc.) the app is throwing the following NoSuchSessionError:
NoSuchSessionError: Tried to run command without establishing a connection
at Object.throwDecodedError (/home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/error.js:514:15)
at parseHttpResponse (/home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/http.js:519:13)
at /home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.quit()
at thenableWebDriverProxy.schedule (/home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at thenableWebDriverProxy.quit (/home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/webdriver.js:840:23)
at /home/ubuntu/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node13/lib/node_modules/selenium-cucumber-js/runtime/world.js:175:27
at ManagedPromise.invokeCallback_ (/home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at /home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/promise.js:2927:27
at /home/ubuntu/workspace/b2b-portal_dev/node_modules/selenium-webdriver/lib/promise.js:668:7
at processTicksAndRejections (internal/process/task_queues.js:93:5)
@john-doherty would you consider instead of relying on the browserName variable set in getDriverInstance() function to query the browserName from the current driver session via the following snippet?
function closeBrowser() {
driver.getCapabilities().then(function (caps) {
browserName = caps.get("browserName");
});
// firefox quits on driver.close on the last window
return driver.close().then(function () {
if (browserName !== 'firefox'){
return driver.quit();
}
});
}
When creating my customDriver.js based on the Firefox driver defined in the selenium-cucumber-js repository mainly to set custom browser Options (headless, private, etc.) the app is throwing the following NoSuchSessionError:
After troubleshooting, the error seems related to the closeBrowser() function where basically Firefox cannot be closed "twice". However, since browserName variable seems not being set for custom driver. https://github.com/john-doherty/selenium-cucumber-js/blob/23d40df5cd1413a163824263b18af55e2c88aeaa/runtime/world.js#L171-L178
@john-doherty would you consider instead of relying on the browserName variable set in getDriverInstance() function to query the browserName from the current driver session via the following snippet?