Skip to content

Commit e1ae1a0

Browse files
committed
Adding new methods to assist with processing downloaded files
1 parent b9fc1fe commit e1ae1a0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class MyTestClass(BaseCase):
3838
from seleniumbase.core.testcase_manager import TestcaseDataPayload
3939
from seleniumbase.core.testcase_manager import TestcaseManager
4040
from seleniumbase.core import browser_launcher
41+
from seleniumbase.core import download_helper
4142
from seleniumbase.core import log_helper
4243
from seleniumbase.fixtures import constants
4344
from seleniumbase.fixtures import page_actions
@@ -688,6 +689,23 @@ def save_file_as(self, file_url, new_file_name, destination_folder=None):
688689
page_utils._download_file_to(
689690
file_url, destination_folder, new_file_name)
690691

692+
def get_downloads_folder(self):
693+
""" Returns the OS path of the Downloads Folder.
694+
(Works with Chrome and Firefox only, for now.) """
695+
return download_helper.get_downloads_folder()
696+
697+
def get_path_of_downloaded_file(self, file):
698+
""" Returns the OS path of the downloaded file. """
699+
return os.path.join(self.get_downloads_folder(), file)
700+
701+
def is_downloaded_file_present(self, file):
702+
""" Checks if the file exists in the Downloads Folder. """
703+
return os.path.exists(self.get_path_of_downloaded_file(file))
704+
705+
def assert_downloaded_file(self, file):
706+
""" Asserts that the file exists in the Downloads Folder. """
707+
assert os.path.exists(self.get_path_of_downloaded_file(file))
708+
691709
def convert_xpath_to_css(self, xpath):
692710
return xpath_to_css.convert_xpath_to_css(xpath)
693711

0 commit comments

Comments
 (0)