Skip to content

Commit

Permalink
Merge pull request #18 from imsardine/failed-to-activate-store-apps
Browse files Browse the repository at this point in the history
Failed to activate store apps
  • Loading branch information
imsardine committed Aug 24, 2015
2 parents b49aca1 + 046a12c commit ad8ae2e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/WinAppDriver/IUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
32 changes: 30 additions & 2 deletions src/WinAppDriver/Modern/StoreApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ad8ae2e

Please sign in to comment.