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

Browser WBT on Chrome: avoid "no such window: target window already closed" #1265

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

ilonatommy
Copy link
Member

Contributes to dotnet/runtime#107466 - when running locally with the new chrome we're getting:

 [wasm test-browser] fail: Error while closing browser: OpenQA.Selenium.NoSuchWindowException: no such window: target window already closed
          [wasm test-browser] from unknown error: web view not found
          [wasm test-browser]   (Session info: chrome=128.0.6613.120)
          [wasm test-browser]          at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
          [wasm test-browser]          at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
          [wasm test-browser]          at OpenQA.Selenium.Remote.RemoteWebDriver.set_Url(String value)
          [wasm test-browser]          at OpenQA.Selenium.Remote.RemoteNavigator.GoToUrl(String url)
          [wasm test-browser]          at Microsoft.DotNet.XHarness.CLI.Commands.Wasm.WasmTestBrowserCommand.InvokeInternal(ILogger logger) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs:line 134

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 do driver.Navigate().GoToUrl("about:config"); in case driverService is still running. It throws OpenQA.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.

@ilonatommy ilonatommy self-assigned this Sep 10, 2024
@ilonatommy ilonatommy added the wasm WASM area label Sep 10, 2024
@ilonatommy
Copy link
Member Author

/ba-g failures not connected. Tested locally - passing without timeouts on the newest Chrome.

@ilonatommy
Copy link
Member Author

/ba-g Android was not touched

@ilonatommy ilonatommy merged commit 6d3cf4f into main Sep 10, 2024
15 of 17 checks passed
@ilonatommy ilonatommy deleted the avoid-no-such-window-exception branch September 10, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasm WASM area
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants