this post was submitted on 17 Mar 2024
3 points (100.0% liked)

Selenium Web Browser Automation

98 readers
1 users here now

Users forum for selenium browser testing. Do not advertise here.

founded 1 year ago
MODERATORS
 

I'm trying to automate a process where I log into a website, download a series of documents, process them, then re-upload. I'm having trouble downloading; the preferences don't seem to work:

chromedriver_path = "C:\\Users\\XXX\\PycharmProjects\\YYY\\util_files\\chromedriver-win64\\chromedriver.exe"
service = Service(chromedriver_path)
options = Options()
options.headless = True
options.add_argument("--incognito")
prefs = {"download.default_directory": "C:\\Users\\XXX\\Downloads",
         "download.prompt_for_download": False,
         "download.directory_upgrade": True}
options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(service=service, options=options)

It doesn't run it headless (not a big deal) but it keeps prompting me with the download dialog. It's tough to find a solution online because it seems like Selenium has updated how it does some things over time, so I don't know of my code is the most up to date or not. TIA

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 7 months ago

Solved it myself; the preferences don't work with incognito mode. -_-