diff --git a/src/WinAppDriver/IUtils.cs b/src/WinAppDriver/IUtils.cs index f09a574..7c3fccd 100755 --- a/src/WinAppDriver/IUtils.cs +++ b/src/WinAppDriver/IUtils.cs @@ -117,9 +117,9 @@ public bool DeleteDirectoryIfExists(string path) // Seems like a timing issue that the built-in Directory.Delete(path, true) // did not take into account. logger.Warn("IOException raised while deleting the directory: {0} ({1})", path, e.Message); - logger.Debug("Sleep for a while (2s), and try again..."); + logger.Debug("Sleep for a while (5s), and try again..."); - System.Threading.Thread.Sleep(2000); + System.Threading.Thread.Sleep(5000); Directory.Delete(path); } diff --git a/src/WinAppDriver/Modern/StoreApp.cs b/src/WinAppDriver/Modern/StoreApp.cs index 6a5f0a4..f4f1267 100755 --- a/src/WinAppDriver/Modern/StoreApp.cs +++ b/src/WinAppDriver/Modern/StoreApp.cs @@ -113,8 +113,36 @@ public bool IsInstalled() public void Activate() { - // TODO thorw exception if needed - Process.Start("ActivateStoreApp", this.AppUserModelId); + logger.Info( + "Activate the store app; current working directory = [{0}], " + + "AppUserModelID = [{1}].", + Environment.CurrentDirectory, this.AppUserModelId); + + var info = new ProcessStartInfo( + Path.Combine(Environment.CurrentDirectory, "ActivateStoreApp.exe"), + this.AppUserModelId); + info.UseShellExecute = false; + info.RedirectStandardOutput = true; + info.RedirectStandardError = true; + + var process = Process.Start(info); + logger.Debug("PID of ActivateStoreApp.exe = {0}.", process.Id); + process.WaitForExit(); + + if (process.ExitCode == 0) + { + logger.Debug("STDOUT = [{0}].", process.StandardOutput.ReadToEnd()); + } + else + { + string msg = string.Format( + "Error occurred while activating the store app; " + + "code = {0}, STDOUT = [{1}], STDERR = [{2}].", + process.ExitCode, + process.StandardOutput.ReadToEnd(), + process.StandardError.ReadToEnd()); + throw new WinAppDriverException(msg); + } } public void Terminate()