protractor-cucumber-framework: WebDriverError: no such session when control flow is disabled and restartBrowserBetweenTests: true

‘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();
});

About this issue

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

Commits related to this issue

Most upvoted comments

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.

This issue is still reproducible in v5.0.0