I am trying to download a file with Selenium and python into a specific relative directory but I can't.
I tried the following codes that I have seen in the web:
options = webdriver.ChromeOptions()
options.add_argument("download.default_directory=/folder")
driver = webdriver.Chrome(chrome_options=options)
and this:
import webdriver
chrome_options = webdriver.ChromeOptions()
prefs = {'download.default_directory' : '/folder'}
chrome_options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(chrome_options=chrome_options)
but they do not work. I also tried the following and it kind of works, but the select location window have to pop up, which I will have to manually click "Select"
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
prefs = {"profile.default_content_settings.popups": 0,
"download.default_directory":
r"C:\Users\user_dir\Desktop\\",#IMPORTANT - ENDING SLASH V IMPORTANT
"directory_upgrade": True}
options.add_experimental_option("prefs", prefs)
browser=webdriver.Chrome(<chromdriver.exe path>, options=options)
Do anyone know why and how to fix it? Or are there any alternative solutions that allow me to know the directory of the file and access the file it just downloaded?