Skip to content

Commit 9e7a948

Browse files
committed
Update methods
1 parent e09e90b commit 9e7a948

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

help_docs/method_summary.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ self.get_path_of_downloaded_file(file, browser=False)
323323
self.is_downloaded_file_present(file, browser=False)
324324

325325
self.delete_downloaded_file_if_present(file, browser=False)
326+
# Duplicates: self.delete_downloaded_file(file, browser=False)
326327

327328
self.assert_downloaded_file(file, timeout=None, browser=False)
328329

seleniumbase/fixtures/base_case.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,7 +3610,29 @@ def delete_downloaded_file_if_present(self, file, browser=False):
36103610
file - The filename to be deleted from the [Downloads Folder].
36113611
browser - If True, uses the path set by click-initiated downloads.
36123612
If False, uses the self.download_file(file_url) path.
3613-
Those paths are often the same. (browser-dependent)
3613+
Those paths are usually the same. (browser-dependent)
3614+
(Default: False).
3615+
"""
3616+
if self.is_downloaded_file_present(file, browser=browser):
3617+
file_path = self.get_path_of_downloaded_file(file, browser=browser)
3618+
try:
3619+
os.remove(file_path)
3620+
except Exception:
3621+
pass
3622+
3623+
def delete_downloaded_file(self, file, browser=False):
3624+
"""Same as self.delete_downloaded_file_if_present()
3625+
Deletes the file from the [Downloads Folder] if the file exists.
3626+
For browser click-initiated downloads, SeleniumBase will override
3627+
the system [Downloads Folder] to be "./downloaded_files/",
3628+
but that path can't be overridden when using Safari, IE,
3629+
or Chromium Guest Mode, which keeps the default system path.
3630+
self.download_file(file_url) will always use "./downloaded_files/".
3631+
@Params
3632+
file - The filename to be deleted from the [Downloads Folder].
3633+
browser - If True, uses the path set by click-initiated downloads.
3634+
If False, uses the self.download_file(file_url) path.
3635+
Those paths are usually the same. (browser-dependent)
36143636
(Default: False).
36153637
"""
36163638
if self.is_downloaded_file_present(file, browser=browser):
@@ -9127,8 +9149,7 @@ def __process_dashboard(self, has_exception, init=False):
91279149
'<tbody class="%s results-table-row">'
91289150
'<tr style="background-color: #F8FFF8;">'
91299151
'<td class="col-result">%s</td><td>%s</td><td>%s</td>'
9130-
"<td>-</td></tr></tbody>"
9131-
% (row[0], row[1], row[2], row[3])
9152+
"<td>-</td></tr></tbody>" % (row[0], row[1], row[2], row[3])
91329153
)
91339154
table_html += row
91349155
for row in the_untested:

0 commit comments

Comments
 (0)