-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[dotnet] quit fails after not successful new session #14242
[dotnet] quit fails after not successful new session #14242
Conversation
PR Reviewer Guide 🔍
|
PR Code Suggestions ✨
|
@Indomitable please share the exception with stacktrace you faced and you are trying to fix. Probably we may propose better solution. |
@nvborisenko Here is my input: selenium/dotnet/src/webdriver/WebDriver.cs Line 651 in 6b28a8c
this leads to calling the Quit() in the catch
which calls Dispose and then the Quit commandselenium/dotnet/src/webdriver/WebDriver.cs Line 706 in 6b28a8c
but since the sessionId is not initialized yet , a NullReferenceException is thrown when tries to build the URL for the quit command
As I wrote in the Java client this is fixed using second try/catch for the quit methodselenium/java/src/org/openqa/selenium/remote/RemoteWebDriver.java Lines 160 to 170 in 6b28a8c
|
I understand the flow how it is happening. I am curious in the stracktrace (what you see in your output). My thoughts:
|
Here is the stack trace. I'm using the Appium.NET library which uses Selenium
|
6b65af8
to
9fd520d
Compare
So it depends from the server. In this case the Appium server returns empty body and we get json deserialization issue. One more problem that I see is that a |
@Indomitable Ok, seems I am right that I propose to align with java implementation, probably they know hidden stones:
So in |
da47cf2
to
ab86f81
Compare
PR is updated with the try/catch around the Quit. |
If new session creation fails a Quit() method is called which calls Dispose and then Quit command, unfortunately in this case session is still not created and it throws null reference exception and this hides the actual exception
In order to propagate the original error when session fails, surround the Quit call in try/catch in case it also throws an exception.
ab86f81
to
ad528bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
* [dotnet] do not execute Quit command when sessionId is not available If new session creation fails a Quit() method is called which calls Dispose and then Quit command, unfortunately in this case session is still not created and it throws null reference exception and this hides the actual exception * [dotnet] ignore exceptions from Quit when new session fails In order to propagate the original error when session fails, surround the Quit call in try/catch in case it also throws an exception. --------- Co-authored-by: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com>
User description
If new session creation fails a Quit() method is called which calls Dispose and then Quit command, unfortunately in this case session is still not created and it throws null reference exception and this hides the actual exception
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Motivation and Context
Types of changes
Checklist
This PR fixes a bug which calls Quit command after trying to create new session. If session fails it calls the Quit method in order to dispose the driver and the commander, unfortunately since the session id is null the Execute Quit command fails with null reference exception.
For reference in Java client this is solved with another try/catch when calling
quit()
but I think checking the session id if null is better solution.PR Type
Bug fix
Description
sessionId
before executing the Quit command inDispose
method to prevent null reference exceptions when session creation fails.Changes walkthrough 📝
WebDriver.cs
Add null check for sessionId before executing Quit command
dotnet/src/webdriver/WebDriver.cs
sessionId
before executing the Quit command.