PID of firefox process on windows/.net?

Showing 1-9 of 9 messages
PID of firefox process on windows/.net? FireGuy 4/15/11 9:36 AM
Hi,

Is there some tricky back-alley way to get the process-id of the
spawned firefox instance?
I'm using webdriver with .Net and firefox.

Thanks
Re: PID of firefox process on windows/.net? Jim Evans 4/15/11 12:34 PM
Not with 100% certainty, unless you hack the FirefoxDriver source
code, specifically the FirefoxBinary class. I'm not sure I understand
why you'd want such a thing, but you could make an educated guess at
the process ID by cleverly using
System.Diagnostic.Process.GetProcessesByName().
Re: [webdriver] Re: PID of firefox process on windows/.net? BillR 4/15/11 5:06 PM
> Is there some tricky back-alley way to get the process-id of the
> spawned firefox instance?
> I'm using webdriver with .Net and firefox.

Not sure if it rises to the level of tricky, let alone
back-alley, but if you launched RC under cygwin, you'd
likely see the pid with 'ps -eaf'. I'm not sure if
cygwin tracks non-cygwin tasks, tend to doubt it. Just
a thought.

Bill

Re: PID of firefox process on windows/.net? FireGuy 4/15/11 8:54 PM
While waiting for an answer I indeed patched the FirefoxDriver and
FirefoxBinary classes to expose the process.
I hate when things exist but are hidden behind privates. Now I will
have to do this with every version forever :-\

In case anyone is interested, I'm spawning multiple webdriver powered
firefox processes, I also interact with them using other tools (which
I run from the same code that runs the webdriver), I just need the pid
to tie everything together in a nice way.

Now that I'm thinking about it some more... if there's an about:config
setting that allows setting (or appending to) the window title - I
could use that to find the correct process... hmm... maybe that is a
better way to solve this.

Thanks for the answers!
Re: PID of firefox process on windows/.net? QA_manager 4/18/11 7:01 AM
Please let us know what you learn and your best solution, so other
people can benefit from your knowledge.
Re: PID of firefox process on windows/.net? FireGuy 4/18/11 8:25 AM
QA_manager - if the information exists, why not make it public?
I presume it is hidden because it is not possible to get this info on
all platforms/browsers, but why not expose it where it exists?

It'll take some for me to actually get to testing alternative methods
of accomplishing this, because I currently have a working solution.
But if anyone is interested - this is the path I would take:

1) Listing processes by title or other methods -
http://www.codeproject.com/KB/threads/ApplicationCheck_CS.aspx
2) Changing firefox title - http://kb.mozillazine.org/Rebranding_Firefox

Thank you
Re: PID of firefox process on windows/.net? Jim Evans 4/18/11 12:54 PM
I thought I'd posted a reply to this over the weekend, but I suppose I
must not have.

Basically, the System.Diagnostics.Process object used to track the
Firefox process in the FirefoxDriver is an internal implementation
detail. I might be convinced that it should be exposed via a protected
property so that it could be accessed via a subclass, but please
realize that this is the first time anyone has asked for such a thing.
It's not part of the public cross-platform, cross-browser API, and as
such it is, and in my opinion ought to be, private.

I can forsee a day that we won't be using System.Diagnostics.Process
for tracking Firefox instances (cf. the new ChromeDriver checked into
the trunk of the project). In that instance, we would be put in the
untenable position of breaking an until-then public API because it
would no longer be applicable.

Regards,
--Jim

On Apr 18, 11:25 am, SeleniuMaddog <madd0g.co...@gmail.com> wrote:
> QA_manager - if the information exists, why not make it public?
> I presume it is hidden because it is not possible to get this info on
> all platforms/browsers, but why not expose it where it exists?
>
> It'll take some for me to actually get to testing alternative methods
> of accomplishing this, because I currently have a working solution.
> But if anyone is interested - this is the path I would take:
>
> 1) Listing processes by title or other methods -http://www.codeproject.com/KB/threads/ApplicationCheck_CS.aspx
> 2) Changing firefox title -http://kb.mozillazine.org/Rebranding_Firefox
> > > > Bill- Hide quoted text -
>
> - Show quoted text -
Re: PID of firefox process on windows/.net? FireGuy 4/27/11 9:47 PM
Ok, so I have a good reason - recover from a browser crash.
Today I found a site in which a certain code always crashes the
browser.
I immediately thought how nice it would be to be able to query if the
browser still running by pid.

Webdriver just seems to timeout while trying to talk to the browser
(that's the exception I've seen, maybe it is somehow handled, I'm not
sure) - but the browser is not revived or anything.

Thanks
Re: PID of firefox process on windows/.net? FireGuy 4/30/11 2:41 PM
Faulting application name: Firefox.exe, version: 1.9.2.4095, time
stamp: 0x4d852c95
Faulting module name: js3250.dll, version: 0.0.0.0, time stamp:
0x4d8523fd
Exception code: 0xc0000005
Fault offset: 0x0007cfc4

I don't even know if it's reproducible outside of my system, can
someone please check if the following crashes their firefox?
My browser always crashes when I run this code with the C# firefox
driver.

driver.Navigate().GoToUrl("http://www.whatismyip.com/");
driver.SwitchTo().DefaultContent();

//Close the ad-popup(s)
while (driver.GetWindowHandles().Count > 1)
{
        var win = driver.GetWindowHandles().Last();
        driver.SwitchTo().Window(win);
        driver.Close();
}
driver.Manage().DeleteAllCookies();


//Thank you!