Skip to content

Commit e56cee3

Browse files
committed
log the found files during download
1 parent 8db1cb1 commit e56cee3

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.openqa.selenium.grid.router;
1919

20+
import static java.util.stream.Collectors.toList;
2021
import static org.assertj.core.api.Assertions.assertThat;
2122
import static org.openqa.selenium.HasDownloads.DownloadedFile;
2223
import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS;
@@ -36,8 +37,6 @@
3637
import java.util.Set;
3738
import java.util.concurrent.ExecutorService;
3839
import java.util.concurrent.Executors;
39-
import java.util.stream.Collectors;
40-
4140
import org.junit.jupiter.api.*;
4241
import org.openqa.selenium.*;
4342
import org.openqa.selenium.chrome.ChromeOptions;
@@ -111,21 +110,26 @@ void canListDownloadedFiles() {
111110
driver.findElement(By.id("file-2")).click();
112111

113112
HasDownloads hasDownloads = (HasDownloads) driver;
114-
new WebDriverWait(driver, Duration.ofSeconds(5))
113+
new WebDriverWait(driver, Duration.ofSeconds(5), Duration.ofMillis(50))
115114
.until(
116-
d ->
117-
hasDownloads.getDownloadableFiles().stream()
118-
// ensure we hit no temporary file created by the browser while
119-
// downloading
120-
.filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith))
121-
.count()
122-
== 2);
115+
d -> {
116+
List<String> files = hasDownloads.getDownloadableFiles();
117+
List<String> matchingFiles =
118+
files.stream()
119+
.filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith))
120+
.collect(toList());
121+
System.out.printf(
122+
"[*****] FOUND %s FILES: %s; MATCHING %s FILES: %s%n",
123+
files.size(), files, matchingFiles.size(), matchingFiles);
124+
// ensure we hit no temporary file created by the browser while downloading
125+
return matchingFiles.size() == 2;
126+
});
123127

124128
List<String> downloadableFiles = hasDownloads.getDownloadableFiles();
125129
assertThat(downloadableFiles).contains("file_1.txt", "file_2.jpg");
126130

127131
List<DownloadedFile> downloadedFiles = hasDownloads.getDownloadedFiles();
128-
assertThat(downloadedFiles.stream().map(f -> f.getName()).collect(Collectors.toList()))
132+
assertThat(downloadedFiles.stream().map(f -> f.getName()).collect(toList()))
129133
.contains("file_1.txt", "file_2.jpg");
130134

131135
driver.quit();

0 commit comments

Comments
 (0)