From 29583632aee54f7e0d3d64e69fdcea6d400baaf3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 Aug 2025 14:45:57 +0000 Subject: [PATCH 1/2] Initial plan From fd59a749ce57df30d5ff1fa8cd04cc3679b3ee38 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 Aug 2025 14:55:00 +0000 Subject: [PATCH 2/2] Add proper UIAutomation cleanup for macOS in AppiumCatalystApp Co-authored-by: jfversluis <939291+jfversluis@users.noreply.github.com> --- .../AppiumApp.cs | 2 +- .../AppiumCatalystApp.cs | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Plugin.Maui.UITestHelpers.Appium/AppiumApp.cs b/src/Plugin.Maui.UITestHelpers.Appium/AppiumApp.cs index dfb6b2e..f4d5e9c 100644 --- a/src/Plugin.Maui.UITestHelpers.Appium/AppiumApp.cs +++ b/src/Plugin.Maui.UITestHelpers.Appium/AppiumApp.cs @@ -150,7 +150,7 @@ protected static void SetGeneralAppiumOptions(IConfig config, AppiumOptions appi appiumOptions.AddAdditionalAppiumOption(MobileCapabilityType.NewCommandTimeout, 3000); } - public void Dispose() + public virtual void Dispose() { _driver?.Dispose(); } diff --git a/src/Plugin.Maui.UITestHelpers.Appium/AppiumCatalystApp.cs b/src/Plugin.Maui.UITestHelpers.Appium/AppiumCatalystApp.cs index 4b41939..8a3cc96 100644 --- a/src/Plugin.Maui.UITestHelpers.Appium/AppiumCatalystApp.cs +++ b/src/Plugin.Maui.UITestHelpers.Appium/AppiumCatalystApp.cs @@ -39,6 +39,44 @@ 3 or } } + public override void Dispose() + { + try + { + // Terminate the app before disposing the driver to ensure proper cleanup on macOS + var appId = Config.GetProperty("AppId"); + if (!string.IsNullOrWhiteSpace(appId) && _driver != null) + { + try + { + _driver.ExecuteScript("macos: terminateApp", new Dictionary + { + { "bundleId", appId }, + }); + } + catch + { + // Ignore errors during app termination as the app may already be closed + } + + // Explicitly quit the driver session to ensure proper cleanup + try + { + _driver.Quit(); + } + catch + { + // Ignore errors during quit as the session may already be terminated + } + } + } + finally + { + // Call the base dispose to handle standard cleanup + base.Dispose(); + } + } + private static AppiumOptions GetOptions(IConfig config) { config.SetProperty("PlatformName", "mac");