Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Plugin.Maui.UITestHelpers.Appium/AppiumApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
38 changes: 38 additions & 0 deletions src/Plugin.Maui.UITestHelpers.Appium/AppiumCatalystApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("AppId");
if (!string.IsNullOrWhiteSpace(appId) && _driver != null)
{
try
{
_driver.ExecuteScript("macos: terminateApp", new Dictionary<string, object>
{
{ "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");
Expand Down