how to make seleniumwire.undetectedchromedriver automatically close webdriver when i…
- User
how to make seleniumwire.undetected_chromedriver automatically close webdriver when i close command prompt controlling it. It works with original selenium but undetected_chromedriver just doesn’t automatically closes so i have an opened google chrome window opened even after i close the script
- Assistant
Unfortunately, there isn't a direct way to make undetected_chromedriver automatically close the webdriver when you close the command prompt.
As a workaround, you can create a batch (.bat) file that will start your Python script, wait for your command, and then kill all instances of the Chrome browser and the webdriver when the command prompt is closed. Follow these steps:
- Create a text file and save it with a
.batextension, for examplerun_script.bat. - In the batch file, write the following commands:
@echo off start python your_script.py pause taskkill /IM chrome.exe /F taskkill /IM chromedriver.exe /F exitReplace
your_script.pywith the name of your Python script.- Run the batch file by double-clicking it or running it from the command prompt. This will start your Python script and wait for you to press any key to close the browsers and the WebDriver.
Remember, this workaround will force close all instances of Chrome browser, so make sure you save your work in other browser windows before closing the command prompt.
- Create a text file and save it with a
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.