1
I implemented a script using Selenium that accesses some pages. The code is working exactly as expected.
My problem is when script finishes its execution which happens in two ways:
- When the user closes the browser (Chromedriver)
- When the user closes the command prompt or interrupts the script (Ctrl+C)
After the closure of the execution, the process 'Chrome.exe' remains active, making files continue to be used and locking them (you cannot delete/move/rename...).
I found out that there are commands to terminate these processes.
browser.close()
will close only the current window.
browser.quit()
close all open windows.
But I need to fire these methods at the right times, have triggers that trigger only when the user finishes the execution.
Any other idea/solution is welcome.
the process remains open in both cases? both with the user closing the window and closing terminal?
– Karl Zillner
@Karlzillner yes, from the moment the webDriver is started
driver = webdriver.Chrome(chrome_options=chrome_options)
, the process remains open in both cases.– Mathiasfc
The expection
except (KeyboardInterrupt, SystemExit):
can help you with Ctrl+C. Usebrowser.close()
and thebrowser.quit()
to finalize the process.– Karl Zillner