question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebDriverError: no such session when control flow is disabled and restartBrowserBetweenTests: true

See original GitHub issue

‘WebDriverError: no such session’ error is thrown on attempt to run test. Test execution begins before session is created.

  • The issue is reproducing with following configuration: – Control flow should be disabled. – restartBrowserBetweenTests: true

  • Is not reproducing when restartBrowserBetweenTests: false and control flow is disabled

  • Is not reproducing when restartBrowserBetweenTests: true and control flow is enabled

  • Is not reproducing with “jasmine”:“2.8.0”

“cucumber”: “4.0.0”, “protractor”: “5.3.0”, “protractor-cucumber-framework”: “4.2.0”

1) Scenario: test scenario # features/aFeatureFile.feature:11
   ✖ Given I execute test # features/homePage_steps.js:1
       WebDriverError: no such session
         (Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.13.2 x86_64)> > > 

config file example

const config = {
    SELENIUM_PROMISE_MANAGER: false,
    baseUrl: "http://www.angularjs.org",
    seleniumAddress: 'http://localhost:4444/wd/hub',
    capabilities: {
        browserName: 'chrome',
        shardTestFiles: false,
        maxInstances: 1
    },
    specs: [
        './features/*.feature'
    ],
    ignoreUncaughtExceptions: true,
    disableChecks: true,
    framework: 'custom',
    frameworkPath: './node_modules/protractor-cucumber-framework',
    restartBrowserBetweenTests: true,
    cucumberOpts: {
        require: './features/homePage_steps.js',
        strict: true,
        format: 'json:results.json',
        defaultTimeoutInterval: 160000,
        tags: "@Regression"
    },
    onPrepare: onPrepare,
    onComplete: onComplete
};

function onPrepare() {
    const {Given, Then, When} = require('cucumber');
    global.Given = Given;
    global.When = When;
    global.Then = Then;
}

function onComplete() {
    console.log("suite tests complete --> ");
}

exports.config = Object.assign({}, config);

log from selenium standalone

10:55:50.199 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
10:55:50.199 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@7c612334
10:55:50.199 INFO - /session: Executing POST on /session (handler: BeginSession)
10:55:50.200 INFO - Capabilities are: Capabilities {count=1, browserName=chrome, maxInstances=1, shardTestFiles=false, }
10:55:50.200 INFO - Capabilities {count=1, browserName=chrome, maxInstances=1, shardTestFiles=false, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
10:55:50.200 INFO - Capabilities {count=1, browserName=chrome, maxInstances=1, shardTestFiles=false, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef) on port 37608
Only local connections are allowed.
10:55:51.045 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@32723eb3
10:55:51.047 INFO - Handler thread for session 374edcf42644e4382becdb360ce402fd (chrome): Executing POST on /session/374edcf42644e4382becdb360ce402fd/timeouts (handler: ServicedSession)
10:55:51.049 INFO - To upstream: {"script":11000}
10:55:51.051 INFO - To downstream: {"sessionId":"374edcf42644e4382becdb360ce402fd","status":13,"value":{"message":"unknown error: 'ms' must be a double\n  (Session info: chrome=63.0.3239.132)\n  (Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.13.2 x86_64)"}}
10:55:51.055 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@32723eb3
10:55:51.055 INFO - Handler thread for session 374edcf42644e4382becdb360ce402fd (chrome): Executing POST on /session/374edcf42644e4382becdb360ce402fd/timeouts (handler: ServicedSession)
10:55:51.056 INFO - To upstream: {"type":"script","ms":11000}
10:55:51.056 INFO - To downstream: {"sessionId":"374edcf42644e4382becdb360ce402fd","status":0,"value":null}
10:55:51.635 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@32723eb3
10:55:51.635 INFO - Handler thread for session 374edcf42644e4382becdb360ce402fd (chrome): Executing POST on /session/374edcf42644e4382becdb360ce402fd/url (handler: ServicedSession)
10:55:51.635 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@32723eb3
10:55:51.636 INFO - To upstream: {"url":"data:text/html,<html></html>"}
10:55:51.637 INFO - Handler thread for session 374edcf42644e4382becdb360ce402fd (chrome): Executing DELETE on /session/374edcf42644e4382becdb360ce402fd (handler: ServicedSession)
10:55:51.679 INFO - To downstream: {"sessionId":"374edcf42644e4382becdb360ce402fd","status":0,"value":null}
10:55:51.685 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@32723eb3
10:55:51.686 INFO - Handler thread for session 374edcf42644e4382becdb360ce402fd (chrome): Executing POST on /session/374edcf42644e4382becdb360ce402fd/execute (handler: ServicedSession)
10:55:51.686 INFO - To upstream: {"script":"window.name = \"NG_DEFER_BOOTSTRAP!\" + window.name;window.location.replace(\"http://www.angularjs.org/\");","args":[]}
10:55:51.729 INFO - To downstream: {"sessionId":"374edcf42644e4382becdb360ce402fd","status":0,"value":null}
10:55:51.730 INFO - Removing session org.openqa.selenium.remote.server.ServicedSession@32723eb3
10:55:51.741 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
10:55:51.741 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@685da0da
10:55:51.741 INFO - /session: Executing POST on /session (handler: BeginSession)
10:55:51.742 INFO - Capabilities are: Capabilities {count=1, browserName=chrome, maxInstances=1, shardTestFiles=false, }
10:55:51.742 INFO - Capabilities {count=1, browserName=chrome, maxInstances=1, shardTestFiles=false, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
10:55:51.742 INFO - Capabilities {count=1, browserName=chrome, maxInstances=1, shardTestFiles=false, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
10:55:51.750 INFO - To downstream: {"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.13.2 x86_64)"}}
10:55:51.750 INFO - To downstream: {"sessionId":"","status":0,"value":null}
Starting ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef) on port 38981
Only local connections are allowed.

test steps

Given("I execute test",{timeout: 5 * 60 * 1000}, async function () {
    console.log(new Date().toISOString() +":"+ ' TEST EXECUTION STARTED');
    await browser.get(browser.baseUrl);
    await browser.close();
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
yugandharreddygorrepaticommented, Sep 25, 2018

Browser. Restart is much needed especially when you run bulk scripts from Jenkins, in my case I should restart the browser after each scenario in cucumber feature due single sign on Login (SSO) mechanism. Restart works perfectly in jasmine… But with cucumber it never works. Not sure y this ppl closed this bug without resolution. I feel ppl are re invented the wheel as WebDriver is very much robust and worked well with angular apps as well. What’s new in protractor I am not understanding.

3reactions
nirmalcraftycommented, May 18, 2018

This issue is still reproducible in v5.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebDriverError: no such session error using ChromeDriver ...
Solution · Initiate the Chrome session configuring ChromeDriver with the argument --disable-impl-side-painting · You may also have to add the ...
Read more >
restart - Protractor - end-to-end testing for AngularJS
If the control flow is disabled, the global browser is replaced asynchronously after the old driver quits. Set by the runner. Example. Code....
Read more >
Webdriver E2E test wrapper for Angular. - GitHub Pages
Session (Object|Capabilities); function protractor.browser. ... controlFlow().execute(function() { let results = actions.map(action => { return ...
Read more >
protractor | Yarn - Package Manager
Protractor is a Node.js program built on top of WebDriverJS. Protractor runs tests against your application running in a real browser, interacting with...
Read more >
CHANGELOG.md
When calling `webdriver.quit`, the control flow is shutdown and will throw an ... quit session to not throw error and quit - should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found