Skip to content

Commit 4ea7207

Browse files
committed
[py] require enabling downloads
1 parent fc45295 commit 4ea7207

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

py/selenium/webdriver/remote/webdriver.py

+9
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,9 @@ def set_user_verified(self, verified: bool) -> None:
11381138
def get_downloadable_files(self) -> dict:
11391139
"""Retrieves the downloadable files as a map of file names and their
11401140
corresponding URLs."""
1141+
if "se:downloadsEnabled" not in self.capabilities:
1142+
raise WebDriverException("You must enable downloads in order to work with downloadable files.")
1143+
11411144
return self.execute(Command.GET_DOWNLOADABLE_FILES)["value"]["names"]
11421145

11431146
def download_file(self, file_name: str, target_directory: str) -> None:
@@ -1146,6 +1149,9 @@ def download_file(self, file_name: str, target_directory: str) -> None:
11461149
file_name: The name of the file to download.
11471150
target_directory: The path to the directory to save the downloaded file.
11481151
"""
1152+
if "se:downloadsEnabled" not in self.capabilities:
1153+
raise WebDriverException("You must enable downloads in order to work with downloadable files.")
1154+
11491155
if not os.path.exists(target_directory):
11501156
os.makedirs(target_directory)
11511157

@@ -1157,4 +1163,7 @@ def download_file(self, file_name: str, target_directory: str) -> None:
11571163

11581164
def delete_downloadable_files(self) -> None:
11591165
"""Deletes all downloadable files."""
1166+
if "se:downloadsEnabled" not in self.capabilities:
1167+
raise WebDriverException("You must enable downloads in order to work with downloadable files.")
1168+
11601169
self.execute(Command.DELETE_DOWNLOADABLE_FILES)

0 commit comments

Comments
 (0)