From 718bc4e7704c7ee9fdc93338b6707ed90c53d847 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Mon, 24 Jun 2024 10:32:30 +0000 Subject: [PATCH 1/2] Close all tabs before quitting. --- .../Commands/WASM/Browser/WasmTestBrowserCommand.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs b/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs index 1b3722cdf..a9838c449 100644 --- a/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs +++ b/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs @@ -103,7 +103,18 @@ protected override async Task InvokeInternal(ILogger logger) token.WaitHandle.WaitOne(); } - driver.Quit(); // Firefox driver hangs if Quit is not issued. + // close all tabs before quit is a workaround for broken Selenium - GeckoDriver communication in Firefox + // https://github.com/dotnet/runtime/issues/101617 + while (driver.WindowHandles.Count > 1) + { + driver.Navigate().GoToUrl("about:config"); + driver.Navigate().GoToUrl("about:blank"); + driver.Close(); //Close Tab + driver.SwitchTo().Window(driver.WindowHandles.Last()); + } + driver.Navigate().GoToUrl("about:config"); + driver.Navigate().GoToUrl("about:blank"); + driver.Quit(); // Firefox driver hangs if Quit is not issued. driverService.Dispose(); driver.Dispose(); } From a64fa94c0613bf478b010d42bb36d65fbf9103d6 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Mon, 24 Jun 2024 13:57:10 +0000 Subject: [PATCH 2/2] Add logging. --- .../Commands/WASM/Browser/WasmTestBrowserCommand.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs b/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs index a9838c449..c9f24e9f5 100644 --- a/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs +++ b/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs @@ -105,6 +105,7 @@ protected override async Task InvokeInternal(ILogger logger) // close all tabs before quit is a workaround for broken Selenium - GeckoDriver communication in Firefox // https://github.com/dotnet/runtime/issues/101617 + logger.LogInformation($"Closing {driver.WindowHandles.Count} browser tabs before setting the main tab to config page and quitting."); while (driver.WindowHandles.Count > 1) { driver.Navigate().GoToUrl("about:config");