Browser WBT on Chrome: avoid "no such window: target window already closed" #1265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributes to dotnet/runtime#107466 - when running locally with the new chrome we're getting:
We have while loop that is closing all the tabs but one. Because there might be delays in closing them, the conditions we're checking might not be deterministic. If because of delays
lastWindowHandle
was null, then we cannot dodriver.Navigate().GoToUrl("about:config");
in casedriverService
is still running. It throwsOpenQA.Selenium.NoSuchWindowException: no such window: target window already closed
then. To avoid it, we have to re-check if there's any window to perform this operation on.We're adding an additional delay before final check for
driverService
.An alternative would be to add a delay inside of the closing tabs loop, but that would not be deterministic and in case of having many tabs, would prolong the test execution. On the other hand, I haven't seen logs with more than 2 tabs attempting to get closed.