Is there a way to know what chrome process comes from chromedrive using python?
Question:
As the question said i want to know if its possible to know what Chrome process comes from ChromeDrive using Python. The problem is that i don’t have the code for the python script that is using the ChromeDrive. So is it possible to kill just the ChromeDrive Chrome with a independent script? Because i want to be able to use the normal chrome and not the ChromeDrive Chrome.
Answers:
If I understood your question, you can use the psutil module to check the running chrome processes, kill the process having ‘webdriver’ in command-line argument.
from contextlib import suppress
import psutil
from selenium.webdriver import Chrome
driver = Chrome()
driver.get('https://stackoverflow.com/questions/59072010/is-there-a-way-to-know-what-chrome-process-comes-from-chromedrive-using-python')
for process in psutil.process_iter():
if process.name() == 'chrome.exe' and '--test-type=webdriver' in process.cmdline():
with suppress(psutil.NoSuchProcess):
process.kill()
import psutil
for process in psutil.process_iter ():
if process.name() == 'chrome.exe':
Name = process.name ()
ID = process.pid
print ("Process name =", Name ,",","Process ID =", ID)
As the question said i want to know if its possible to know what Chrome process comes from ChromeDrive using Python. The problem is that i don’t have the code for the python script that is using the ChromeDrive. So is it possible to kill just the ChromeDrive Chrome with a independent script? Because i want to be able to use the normal chrome and not the ChromeDrive Chrome.
If I understood your question, you can use the psutil module to check the running chrome processes, kill the process having ‘webdriver’ in command-line argument.
from contextlib import suppress
import psutil
from selenium.webdriver import Chrome
driver = Chrome()
driver.get('https://stackoverflow.com/questions/59072010/is-there-a-way-to-know-what-chrome-process-comes-from-chromedrive-using-python')
for process in psutil.process_iter():
if process.name() == 'chrome.exe' and '--test-type=webdriver' in process.cmdline():
with suppress(psutil.NoSuchProcess):
process.kill()
import psutil
for process in psutil.process_iter ():
if process.name() == 'chrome.exe':
Name = process.name ()
ID = process.pid
print ("Process name =", Name ,",","Process ID =", ID)