Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

I would like to get the PID of the browser launched by selenium. Is there any way to get it done?

1 Answer

0 votes
by (62.9k points)

Using the Python API, it's pretty simple:

from selenium import webdriver browser = 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 process import psutil p = psutil.Process(c.service.process.pid) print p.get_children(recursive=True)

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...