seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.5k stars 916 forks source link

Configure the path to `downloaded_files` folder #1715

Closed dylandoamaral closed 1 year ago

dylandoamaral commented 1 year ago

Hello I would like to custom the path to downloaded_files. Is it possible ? I found nothing in the issues/documentation.

mdmintz commented 1 year ago

Duplicate of https://github.com/seleniumbase/SeleniumBase/issues/1557#issuecomment-1287636878


SeleniumBase creates the downloaded_files folder in the working directory where pytest is invoked. Any click-initiated downloads will go there. It's also used for any special files needed. It also holds lock files to prevent issues with multi-threading. The folder resets at the start of every new pytest run so that past test runs don't interfere with new ones. The folder is hard-coded there to prevent issues. And since the folder is reset at the start of new pytest runs, you wouldn't want to use any other existing folders for it.

There are lots of built-in test methods that are specially made for that folder, such as:

self.get_downloads_folder()

self.get_browser_downloads_folder()

self.get_path_of_downloaded_file(file)

self.is_downloaded_file_present(file)

self.delete_downloaded_file_if_present(file)
# Duplicates: self.delete_downloaded_file(file)

self.assert_downloaded_file(file)

If you need files in a different folder, use Python os, sys, and shutil libraries for copying the files you need into a different folder after they get downloaded to the downloaded_files folder.

dylandoamaral commented 1 year ago

It actually writes the file in a read only location that I can't manage myself. I don't think copying the files would work. Never mind if it is not possible. Thank you for your hard work !