diff --git a/src/common/UITestAutomation/SessionHelper.cs b/src/common/UITestAutomation/SessionHelper.cs index 7bb1f6e7a6..5832ac0cc8 100644 --- a/src/common/UITestAutomation/SessionHelper.cs +++ b/src/common/UITestAutomation/SessionHelper.cs @@ -71,6 +71,7 @@ namespace Microsoft.PowerToys.UITest try { appDriver?.Kill(); + appDriver?.WaitForExit(); } catch (Exception ex) { diff --git a/src/common/UITestAutomation/UITestBase.cs b/src/common/UITestAutomation/UITestBase.cs index 1d6502ac54..5d37ea45dd 100644 --- a/src/common/UITestAutomation/UITestBase.cs +++ b/src/common/UITestAutomation/UITestBase.cs @@ -31,11 +31,6 @@ namespace Microsoft.PowerToys.UITest this.Session = new Session(this.sessionHelper.GetRoot(), this.sessionHelper.GetDriver()); } - ~UITestBase() - { - this.sessionHelper.Cleanup(); - } - /// /// Initializes the test. /// @@ -53,6 +48,15 @@ namespace Microsoft.PowerToys.UITest } } + /// + /// Initializes the test. + /// + [TestCleanup] + public void TestCleanup() + { + this.sessionHelper.Cleanup(); + } + /// /// Finds an element by selector. /// Shortcut for this.Session.Find(by, timeoutMS)