@@ -1138,6 +1138,9 @@ def set_user_verified(self, verified: bool) -> None:
1138
1138
def get_downloadable_files (self ) -> dict :
1139
1139
"""Retrieves the downloadable files as a map of file names and their
1140
1140
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
+
1141
1144
return self .execute (Command .GET_DOWNLOADABLE_FILES )["value" ]["names" ]
1142
1145
1143
1146
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:
1146
1149
file_name: The name of the file to download.
1147
1150
target_directory: The path to the directory to save the downloaded file.
1148
1151
"""
1152
+ if "se:downloadsEnabled" not in self .capabilities :
1153
+ raise WebDriverException ("You must enable downloads in order to work with downloadable files." )
1154
+
1149
1155
if not os .path .exists (target_directory ):
1150
1156
os .makedirs (target_directory )
1151
1157
@@ -1157,4 +1163,7 @@ def download_file(self, file_name: str, target_directory: str) -> None:
1157
1163
1158
1164
def delete_downloadable_files (self ) -> None :
1159
1165
"""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
+
1160
1169
self .execute (Command .DELETE_DOWNLOADABLE_FILES )
0 commit comments