Verify how many instances of an application is running

Ask general questions here.
LPG
Posts: 39
Joined: Mon Jul 25, 2011 6:12 pm

Verify how many instances of an application is running

Post by LPG » Mon Mar 19, 2012 4:34 pm

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

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: Verify how many instances of an application is running

Post by sdaly » Mon Mar 19, 2012 5:20 pm

Code: Select all

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

LPG
Posts: 39
Joined: Mon Jul 25, 2011 6:12 pm

Re: Verify how many instances of an application is running

Post by LPG » Mon Mar 19, 2012 9:46 pm

Worked like a charm, thank you. Didn't know I could use IList that way.

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Verify how many instances of an application is running

Post by artur_gadomski » Tue Mar 20, 2012 10:12 am

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.

hadesl
Posts: 2
Joined: Wed Apr 11, 2012 8:45 am

Re: Verify how many instances of an application is running

Post by hadesl » Wed Apr 11, 2012 9:04 am

Thank you for your post, but I just open task manager and see it.