Get PID of Browser launched by selenium
Using the Python API, it's pretty simple:
from selenium import webdriverbrowser = webdriver.Firefox()print browser.binary.process.pid# browser.binary.process is a Popen object...
If you're using Chrome, it's a little more complex, you go via a chromedriver process:
c = webdriver.Chrome()c.service.process # is a Popen instance for the chromedriver processimport psutilp = psutil.Process(c.service.process.pid)print p.get_children(recursive=True)
hwjp's solution isn't working anymore for me, but the solution from ABM is working for other browsers too in case anyone is wondering, so for firefox as of now:
from selenium import webdriverdriver = webdriver.Firefox()print(driver.service.process.pid)
can't comment because of reputation, so I'm submitting this as separate answer...
If you're using PhantomJS then you can get the PID from the process Popen object:
from selenium import webdriverbrowser = webdriver.PhantomJS()print browser.service.process.pid