How to get PID of app an adaptor is in?

Class library usage, coding and language questions.
JayInMA
Posts: 10
Joined: Thu Jan 10, 2013 5:10 pm

How to get PID of app an adaptor is in?

Post by JayInMA » Fri May 02, 2014 1:07 pm

I need to know how to get the Process ID of the app for a given Adapter

WebDocument wd1 = Host.Local.FindSingle<WebDocument>(new Ranorex.Core.RxPath("/dom[@domain='FOO']"), NUnitHelper.RanorexSearchTimeout);

How do I get the PID of the browser?

This could easily be a Form or some other item, not just restricted to browsers, we have several apps open and I want to know which process I am going to act on when I manipulate the adapter.

- Jason

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to get PID of app an adaptor is in?

Post by krstcs » Fri May 02, 2014 1:56 pm

When you start the browser the Host.Local.OpenBrowser() method will return the PID. It is the same with any other application startup in Ranorex, using Host.Local.RunApplication() or Host.Local.RunMobileApp().

Code: Select all

string BrowserProcessID = Host.Local.OpenBrowser(url, browser, browserArgs, killExisting, maximised).ToString();
You will need to do this in user code.
Shortcuts usually aren't...

JayInMA
Posts: 10
Joined: Thu Jan 10, 2013 5:10 pm

Re: How to get PID of app an adaptor is in?

Post by JayInMA » Fri May 02, 2014 8:20 pm

krstcs wrote:When you start the browser the Host.Local.OpenBrowser() method will return the PID. It is the same with any other application startup in Ranorex, using Host.Local.RunApplication() or Host.Local.RunMobileApp().

Code: Select all

string BrowserProcessID = Host.Local.OpenBrowser(url, browser, browserArgs, killExisting, maximised).ToString();
You will need to do this in user code.
It's not really what I asked.. I have an adapter could be from a browser or something else..

say Unknown foo

I want to know the process of the UI element foo is an adapter for , All I have is Foo

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to get PID of app an adaptor is in?

Post by krstcs » Mon May 05, 2014 2:17 pm

The method I mentioned is probably the best way to do it.

However, there may be another way.

The webdocument object has a "Browser" property that holds a reference to the form containing this dom. You might be able to use that to find the PID, but I'm not seeing anything in the documentation.

(We're currently rebuilding the system that I have my license server on so I can't test it...)
Shortcuts usually aren't...