From 6187bc6d2f5cf007f3996c42a63b7df07f79a027 Mon Sep 17 00:00:00 2001 From: Jeremy Kao Date: Thu, 20 Aug 2015 19:05:26 +0800 Subject: [PATCH 1/3] [Fixed] Failed to activate store apps. #12 #17 Use absolute path to refer to ActivateStoreApp.exe. --- src/WinAppDriver/Modern/StoreApp.cs | 32 +++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/WinAppDriver/Modern/StoreApp.cs b/src/WinAppDriver/Modern/StoreApp.cs index 6a5f0a4..7764839 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(5 * 1000); + + 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() From a03a7d336dd64d78842de5f22ac816fcdadb5f95 Mon Sep 17 00:00:00 2001 From: Jeremy Kao Date: Thu, 20 Aug 2015 19:12:08 +0800 Subject: [PATCH 2/3] [Fixed] 2s is too optimistic? --- src/WinAppDriver/IUtils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } From 046a12ca260a296816c0cbc44294503e15ed4834 Mon Sep 17 00:00:00 2001 From: Jeremy Kao Date: Mon, 24 Aug 2015 09:48:09 +0800 Subject: [PATCH 3/3] [Fixed] Timing issue. --- src/WinAppDriver/Modern/StoreApp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WinAppDriver/Modern/StoreApp.cs b/src/WinAppDriver/Modern/StoreApp.cs index 7764839..f4f1267 100755 --- a/src/WinAppDriver/Modern/StoreApp.cs +++ b/src/WinAppDriver/Modern/StoreApp.cs @@ -127,7 +127,7 @@ public void Activate() var process = Process.Start(info); logger.Debug("PID of ActivateStoreApp.exe = {0}.", process.Id); - process.WaitForExit(5 * 1000); + process.WaitForExit(); if (process.ExitCode == 0) {