mherrmann / helium

Lighter web automation with Python
MIT License
4.92k stars 374 forks source link

(Python) Firefox Options don't allow relative paths for browser.download.dir #123

Open KatMerrill opened 3 months ago

KatMerrill commented 3 months ago

Hi! I am using Helium with Firefox, and I was trying to set the FirefoxOptions so that all downloads automatically go to a specified folder. I was able to do this using the full path of the desired folder, but using a relative path such as "./downloads", ".\downloads", or ".downloads" does not seem to work. Is it possible for someone to add this functionality? (Or does it already exist and I'm doing something wrong?)

Here is the code I am using:

options = FirefoxOptions()
options.set_preference("browser.download.useDownloadDir", True)
options.set_preference("browser.download.folderList", 2)
options.set_preference("browser.download.dir", download_directory)
driver = start_firefox(options=options)

where download_directory is set to either a full path (ie. "C:\..."), which does work, or to a relative path (ie. "./downloads"), which did not.