Page 1 of 1

Verify how many instances of an application is running

Posted: Mon Mar 19, 2012 4:34 pm
by LPG
Hi,

I am trying to check how many instances of an application (Adobe Reader) that is running.

Let's say I assume that there will be 3 Adobe Reader's open. To check that the 3rd one is open, I can do the following:

Validate.Exists("/form[@title='Report' and @processname='AcroRd32' and @class='AcrobatSDIWindow' and @instance='2']");]

However, this way I have to know the largest instance number. What I rather need to do, is to get a count of the number of instances. Or get the largest instance number that exists for that process. Same thing :)

Ideas?

Thanks

Re: Verify how many instances of an application is running

Posted: Mon Mar 19, 2012 5:20 pm
by sdaly

Code: Select all

iList<Ranorex.Form> apps = Host.Local.Find<Ranorex.Form>("/form[@processname='AcroRd32']);
Report.Info("Instance count = " + apps.count.ToString());

Re: Verify how many instances of an application is running

Posted: Mon Mar 19, 2012 9:46 pm
by LPG
Worked like a charm, thank you. Didn't know I could use IList that way.

Re: Verify how many instances of an application is running

Posted: Tue Mar 20, 2012 10:12 am
by artur_gadomski
I would use System.Diagnostics.Process.GetProcessesByName() (http://msdn.microsoft.com/en-us/library/z3w4xdc9.aspx) rather than Ranorex version. unless of course you need to do something with those forms.

Re: Verify how many instances of an application is running

Posted: Wed Apr 11, 2012 9:04 am
by hadesl
Thank you for your post, but I just open task manager and see it.