Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchSessionError with custom Firefox driver #103

Open
kjaouadi opened this issue Jun 2, 2020 · 0 comments
Open

NoSuchSessionError with custom Firefox driver #103

kjaouadi opened this issue Jun 2, 2020 · 0 comments

Comments

@kjaouadi
Copy link

kjaouadi commented Jun 2, 2020

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)

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.

function closeBrowser() {
// firefox quits on driver.close on the last window
return driver.close().then(function () {
if (browserName !== 'firefox'){
return driver.quit();
}
});
}

@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();
        }
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant