Skip to content

Commit

Permalink
#2550 #2567 remove CDP listeners after downloading a file
Browse files Browse the repository at this point in the history
  • Loading branch information
asolntsev committed Feb 3, 2024
1 parent 2bbc1dc commit cff9d3e
Showing 1 changed file with 16 additions and 11 deletions.
Expand Up @@ -65,18 +65,23 @@ public File download(WebElementSource anyClickableElement,
// Perform action an element that begins download process
action.perform(anyClickableElement.driver(), clickable);

// Wait until download
File file = waitUntilDownloadsCompleted(anyClickableElement.driver(), timeout, downloadComplete, fileName);

//
if (!fileFilter.match(new DownloadedFile(file, emptyMap()))) {
String message = String.format("Failed to download file in %d ms.%s;%n actually downloaded: %s",
timeout, fileFilter.description(), file.getAbsolutePath());
throw new FileNotDownloadedError(driver, message, timeout);
}
try {
// Wait until download
File file = waitUntilDownloadsCompleted(anyClickableElement.driver(), timeout, downloadComplete, fileName);

//
if (!fileFilter.match(new DownloadedFile(file, emptyMap()))) {
String message = String.format("Failed to download file in %d ms.%s;%n actually downloaded: %s",
timeout, fileFilter.description(), file.getAbsolutePath());
throw new FileNotDownloadedError(driver, message, timeout);
}

// Move file to unique folder
return archiveFile(anyClickableElement.driver(), file);
// Move file to unique folder
return archiveFile(anyClickableElement.driver(), file);
}
finally {
devTools.clearListeners();
}
}

@Nonnull
Expand Down

0 comments on commit cff9d3e

Please sign in to comment.