Skip to content

Commit ad8ae2e

Browse files
committed
Merge pull request #18 from imsardine/failed-to-activate-store-apps
Failed to activate store apps
2 parents b49aca1 + 046a12c commit ad8ae2e

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/WinAppDriver/IUtils.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public bool DeleteDirectoryIfExists(string path)
117117
// Seems like a timing issue that the built-in Directory.Delete(path, true)
118118
// did not take into account.
119119
logger.Warn("IOException raised while deleting the directory: {0} ({1})", path, e.Message);
120-
logger.Debug("Sleep for a while (2s), and try again...");
120+
logger.Debug("Sleep for a while (5s), and try again...");
121121

122-
System.Threading.Thread.Sleep(2000);
122+
System.Threading.Thread.Sleep(5000);
123123
Directory.Delete(path);
124124
}
125125

src/WinAppDriver/Modern/StoreApp.cs

+30-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,36 @@ public bool IsInstalled()
113113

114114
public void Activate()
115115
{
116-
// TODO thorw exception if needed
117-
Process.Start("ActivateStoreApp", this.AppUserModelId);
116+
logger.Info(
117+
"Activate the store app; current working directory = [{0}], " +
118+
"AppUserModelID = [{1}].",
119+
Environment.CurrentDirectory, this.AppUserModelId);
120+
121+
var info = new ProcessStartInfo(
122+
Path.Combine(Environment.CurrentDirectory, "ActivateStoreApp.exe"),
123+
this.AppUserModelId);
124+
info.UseShellExecute = false;
125+
info.RedirectStandardOutput = true;
126+
info.RedirectStandardError = true;
127+
128+
var process = Process.Start(info);
129+
logger.Debug("PID of ActivateStoreApp.exe = {0}.", process.Id);
130+
process.WaitForExit();
131+
132+
if (process.ExitCode == 0)
133+
{
134+
logger.Debug("STDOUT = [{0}].", process.StandardOutput.ReadToEnd());
135+
}
136+
else
137+
{
138+
string msg = string.Format(
139+
"Error occurred while activating the store app; " +
140+
"code = {0}, STDOUT = [{1}], STDERR = [{2}].",
141+
process.ExitCode,
142+
process.StandardOutput.ReadToEnd(),
143+
process.StandardError.ReadToEnd());
144+
throw new WinAppDriverException(msg);
145+
}
118146
}
119147

120148
public void Terminate()

0 commit comments

Comments
 (0)