How do I identify a console process?
How do I identify a console process?
I am using Ranorex 4.0 under Windows 8.1 64-bit. My test case requires to run a helper application that has no GUI, and to wait for this application to finish before the test case continues. I can launch the application by a "Run application" step, but how can I use "Wait for" to wait until the console application has finished?
Re: How do I identify a console process?
Hi,
Ranorex 4.0 is pretty old and I doubt there is anyone who can even remember its coding possibilities? Generally speaking, you should be able to write a "search process" method, in which you can wait for the process termination.
Here are few process -related examples, whcih should help you with writing such method:
https://stackoverflow.com/questions/262 ... is-running
https://social.msdn.microsoft.com/Forum ... nning-in-c
https://support.microsoft.com/en-us/hel ... g-visual-c
Ranorex 4.0 is pretty old and I doubt there is anyone who can even remember its coding possibilities? Generally speaking, you should be able to write a "search process" method, in which you can wait for the process termination.
Here are few process -related examples, whcih should help you with writing such method:
https://stackoverflow.com/questions/262 ... is-running
https://social.msdn.microsoft.com/Forum ... nning-in-c
https://support.microsoft.com/en-us/hel ... g-visual-c
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: How do I identify a console process?
Sorry... I read the wrong line in the "About" dialog. Ranorex version is 8.2.1 Downloaded and installed today...
Re: How do I identify a console process?
Good In any case, you will have to write your own method to wait for the end of process. The links I posted should help you with this task.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: How do I identify a console process?
I had hoped it's built into Ranorex. Thanks anyway...
Re: How do I identify a console process?
Nope, there is no such "wait" available. Existing wait actions are UI related
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: How do I identify a console process?
Hi,
The easiest way would be to start the application through code and wait for the exit code of it.
Hope that helps.
ASDF
The easiest way would be to start the application through code and wait for the exit code of it.
Code: Select all
using System.Diagnostics;
...
Process process = new Process(); // Configure the process using the StartInfo properties.
process.StartInfo.FileName = "process.exe";
process.StartInfo.Arguments = "-YourArguments";
process.Start();
process.WaitForExit();// Waits here for the process to exit.
ASDF
Re: How do I identify a console process?
Ok, that would be a complete action that launches the console app and only returns when the app has terminated. What if I wanted to do something else while the app is running, and at some later step of my test case wait for the app to terminate? Can I write a function with a signature like 'bool ProcessExists(string procName)', and use it in a 'Wait for' action?
Re: How do I identify a console process?
I solved the problem. Thank you for pointing me into the correct direction
Code: Select all
[UserCodeMethod]
public static void RunProgramAndWait(string path, string args, int waitSeconds)
{
Process process = new Process(); // Configure the process using the StartInfo properties.
process.StartInfo.FileName = path;
process.StartInfo.Arguments = args;
if (!process.Start())
throw new RanorexException("Could not create process '" + path + "'");
if (!process.WaitForExit(waitSeconds * 1000))
throw new RanorexException("Process '" + path + "' failed to terminate within " + waitSeconds.ToString() + " seconds");
}