I have tried a lot to set a custom path for downloads while using webdriver-manager 3.8.4
for my script. Whenever my script tries to download a file, the download keeps failing. I do not get any error in the console which makes it worse.
The steps I tried to fix my problem:
- Update chrome browser
- Reinstall
webdriver-manager 3.8.4
- Try a different location
- Manually click on download while the script runs
None of them seems to work. However, the default download location has no issues.
My main concern is how do I set a custom download path with webdriver-manager in Selenium python?
new_dir = r"D:/Selenium/Insights/" + datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
print(new_dir)
if not os.path.exists(new_dir):
#pass
os.makedirs(new_dir)
prefs = {"download.default_directory": new_dir, "download.directory_upgrade": True}
print(prefs)
options=Options()
options.add_argument('--start-maximized')
options.add_experimental_option("prefs", prefs)
self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options)