We can PID of browsers launched by Selenium webdriver. First of all, we have to create an object of the webdriver. Next, for example, to launch the browser in the Firefox browser, we have to take the help of webdriver.Firefox() class.
The location of the geckodriver.exe file is passed as a parameter to that class. This is done by setting the path to executable_path property. Then, the browser shall be launched with the get method.
Finally, to obtain the PID of the browser, we shall use the driver.service.process.id method.
s = driver.service.process.pid
from selenium import webdriver #path of geckodriver.exe driver = webdriver.Firefox(executable_path="C:\\geckodriver.exe") #launch browser driver.get ("https://www.tutorialspoint.com/index.htm") #obtain PID of browser s = driver.service.process.pid print(s) #close browser driver.close()