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

Using browser.end with cucumber results into Error #3332

Closed
gravityvi opened this issue Aug 10, 2022 · 5 comments · Fixed by #4209
Closed

Using browser.end with cucumber results into Error #3332

gravityvi opened this issue Aug 10, 2022 · 5 comments · Fixed by #4209

Comments

@gravityvi
Copy link
Member

Describe the bug

Using browser.end inside cucumber tests ends the session but Nightwatch still tries to close the session at the end of cucumber test suite which results into an error.

Sample test

sampleTest.js

// Use this step definition at the end of a feature file.
Then('the test ends', () => {
  return browser
    .end()
})

Run with command

$ nightwatch test/sampleTest.js --your-other-arguments-here

Verbose output

debug.log

<!-- Include the verbose output, if possible (run nightwatch with `--verbose` argument) -->
 → Running command: end ()
 
 → Running command: session ('delete', [Function])
   Request DELETE /session/a0baebb1-de88-4d02-8f2c-04e8083d0200  

   Response 200 DELETE /session/a0baebb1-de88-4d02-8f2c-04e8083d0200 (562ms)
   { value: null }
  → Completed command: session ('delete', [Function]) (565ms)
 Wrote log file to: /Users/ravi/Documents/Projects/nightwatch/logs/_geckodriver.log.
  → Completed command: end () (574ms)
.Debugger listening on ws://127.0.0.1:63035/7d4dfcbe-d2e2-4ce5-9f04-72f3cec47e78
For help, see: https://nodejs.org/en/docs/inspector
 GeckoDriver process closed.
 
 → Running command: quit ()
  → Error

    Error while running .sessionAction() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: quit () (1ms)

Configuration

nightwatch.json

// NIghtwatch-default-config

Your Environment

Executable Version
nightwatch --version 2.3.0
npm --version VERSION
yarn --version VERSION
node --version VERSION
Browser driver Version
NAME VERSION
OS Version
NAME VERSION
@gravityvi gravityvi added bug cucumber Issues related to Cucumber Test runner complexity: low labels Aug 10, 2022
@vinodreddy-bs
Copy link
Contributor

Will pick this

@gravityvi
Copy link
Member Author

Thanks @vinodreddy-bs, I am not sure if this is still an error in the latest nightwatch version. Could you verify it? Let us know if you need any help

@We2Am-BaSsem
Copy link

We2Am-BaSsem commented Feb 25, 2024

@AutomatedTester @gravityvi
hi I'm interested to work on this issue could it be assigned to me?

@We2Am-BaSsem
Copy link

image
I have reached this code from lib/runner/test-runners/cucumber/_setup_cucumber_runner.js

this force a quit whenever the user run with cucumber which I think it's unwanted behavior
and this needs to be removed(and this will fix the issue)

@garg3133
Copy link
Member

this force a quit whenever the user run with cucumber which I think it's unwanted behavior

This is not an unwanted behaviour, it can just be repetitive sometimes. If we remove this and don't use browser.end() in the test cases, the browser will never close.

So, we still need to keep that statement, but only run it if the session is not closed yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants