Skip to content

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

Merged
ilonatommy merged 4 commits intomainfrom
avoid-no-such-window-exception
Sep 10, 2024
Merged

Browser WBT on Chrome: avoid "no such window: target window already closed"#1265
ilonatommy merged 4 commits intomainfrom
avoid-no-such-window-exception

Conversation

@ilonatommy
Copy link
Copy Markdown
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
Copy Markdown
Member Author

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

Comment thread src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs Outdated
@ilonatommy
Copy link
Copy Markdown
Member Author

/ba-g Android was not touched

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