-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
"Session ID is null. Using WebDriver after calling quit()?" or "NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used." when next scenario runs #709
Comments
Can you please provide the output? I just tested a very small example where I create a webdriver in the world constructor and quit in an after hook and it works fine with multiple scenarios (using selenium webdriver directly, not protractor). |
@charlierudolph Did you try my case (files mentioned above)? |
webdrive console
cucumber console
|
@ThaKing your example is huge and appears to be missing some dependencies. Your code references a file It looks like some errors may not be being reported in your driver.quit().then(function () {
callback();
}) With the above code you are not covering the case that the Cucumber support steps/hooks that return promises, so I would advise switching to only using promises. Also I try to never let a step/hook timeout. If you implement your own timeouts on the step internals, you get a useful error message about why the step failed instead of the very un-useful message: Overall, I am confident cucumber is not allowing one scenario to effect another and hopefully by getting those other errors reported you will be able to determine the issue. |
This timeout
I used for example. In real life I have method which do something, but it failed by and after this timeout the next scenario fails by exception.
Maybe, this is not a cucumber-js issue than thank you for help |
Hi, I am experiencing the same issue. (1st scenario timeout, 2nd immediately shows error of "WebDriverError: Session ID is null. Using WebDriver after calling quit()?") Have you found any solution to that? |
@pantherqin we started to rewrite our tests to the Promises and seems the error disappeared |
@ThaKing what do you mean by rewrite tests to the promises, please? |
I did one solution to this failure when you used the restartBrowserBetweenTests: true, when the browser restart it lost the references because of that it couldn't interact with the page, to solve this problem you have to do one function in an object to initialize the locators, that function must be called always you will run the test. In my repository has a solution that I did: https://github.com/tuliobluz/protractor-cucumber-pageobject PageObejct File: e2e/pages/spec.po.js
Spec file: e2e/specs/spec.spec.js
|
I done the same code but till is get the " Error: function timed out, ensure the callback is executed within 72000 milliseconds" |
I sent to you, how to fix this. |
I was having the same issue. On investigating and debugging for hours I noticed that our framework is creating a new driver instance only when the driver instance is null and is returning the previous instance if it's not null. I assume calling driver.quit() doesn't automatically assign a null value to the current driver instance, hence I resolved the issue by explicitly setting the value as null on my After hook. |
@sumbhatt11 What does the code look like that you wrote to address this issue? |
I was getting the same error. As @sumbhatt11 did, I searched for it for hours. I have a Driver.java class to be able to have only 1 driver. Its the singleton logic. If there is already a driver, I use it by calling Driver.getDriver method that I coded. By using this methodology, I solved the error. It provides only 1 driver and only 1 session ID as far as I understood. Don't use static WebDrivers in every class. Create a Driver class, code a driver initializer and getter method. |
Precondition:
test.feature
world.js
index.js
steps.js
Steps to reproduce:
1.The First scenario has fallen by DefaultTimeout (more than 30 secs as mentioned before in world.js)
2. The second scenario starts
Actual result:
The second scenario failed with "Session ID is null. Using WebDriver after calling quit()?" exception. But
third one is passed.
Expected result
The second scenario should passed too. The previous tests should not impact another
The text was updated successfully, but these errors were encountered: