Process.waitforexit() always returning false.

  • Thread starter Thread starter adtiwari12
  • Start date Start date
A

adtiwari12

Guest
Hello,

I have a test automation project in which i am starting a process, and the process is always returning false even after the process is completed.

Steps:

I have a test case in which i am opening a IE browser window, performing the case and closing the window.

foreach (string value in testSuiteArray)
{
String Cmda = "\"" + MSTestEXEPath + "\"" + " /testsettings:" + ProjectPath + @"\KastleSysTestConfig.testsettings"
+ " /testcontainer:KastleSysTestAutomation.dll /test:" + value + ">" + ProjectPath + "\\CmdLog.txt";
Console.WriteLine(Cmda);
Process Pros = ExecuteCommandSync(Cmda);
while(!Pros.WaitForExit(2000));
}

Cmda contains the command information that is

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\MSTest.exe" /testsettings:D:\project\AutomationSecond\myKAndKDAutomation\AutomationExecutableFiles\KastleSysTestConfig.testsettings /testcontainer:KastleSysTestAutomation.dll /test:KSYS6133Test>D:\project\AutomationSecond\myKAndKDAutomation\AutomationExecutableFiles\CmdLog.txt

Method ExecuteCommandSync(Cmda); contains the below mention code.

ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/K " + command);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
return proc;


Problem is Pros.WaitForExit() always returning false.

I am using Windows 10 Visual Studio 2017 Professional

Continue reading...
 
Back
Top