-
I'm currently using SeleniumBase for my testing, and I've encountered an issue where downloaded files have the same filenames. This could be problematic, especially when running tests in parallel using pytest-xdist, as I won't be able to differentiate between files downloaded by different test cases. I'm curious about how SeleniumBase handles this scenario. I understand that SeleniumBase creates a downloaded_files folder in the working directory where downloads are stored. However, could you explain how SeleniumBase uses lock files to prevent conflicts when multiple tests are running concurrently? Additionally, I'd like to know if there's a way to specify a custom download folder for each test case. This would be helpful for organizing downloaded files and ensuring that they are associated with the correct test case, especially when running tests in parallel. Thank you for your assistance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Already discussed here #1557 (comment) SeleniumBase creates the 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)
self.get_downloaded_files(regex=None, browser=False)
self.get_data_from_downloaded_file(file, timeout=None, browser=False)
self.assert_data_in_downloaded_file(data, file, timeout=None, browser=False) If you need files in a different folder, use Python There's also a Line 673 in 570910c (A copy of those downloads will go into a folder in the There's also this, where you can customize the location: download_file(file_url, destination_folder=None)
"""Downloads the file from the url to the destination folder.
If no destination folder is specified, the default one is used.
(The default folder for downloads is "./downloaded_files")""" |
Beta Was this translation helpful? Give feedback.
Already discussed here #1557 (comment)
SeleniumBase creates the
downloaded_files
folder in the working directory wherepytest
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 newpytest
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 newpytest
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: