I would like to get the PID of the browser launched by selenium. Is there any way to get it done?
I solved it this way:
I am on a Linux OS using Python to detect Firefox memory usage:
import psutil
# Get pid of geckodriver
webdriver_pid = driver.service.process.pid
# Get the process of geckodriver
process = psutil.Process(webdriver_pid)
# Get memory of geckodriver + firefox
# Since memory is in bytes divide by 1024*1024 to obtain result in MB
total_memory = sum([x.memory_info().rss/1048576 for x in process.children() + [process]])