|
21 | 21 | import static org.openqa.selenium.testing.drivers.Browser.IE;
|
22 | 22 | import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
|
23 | 23 |
|
24 |
| -import java.io.BufferedReader; |
25 |
| -import java.io.ByteArrayInputStream; |
26 | 24 | import java.io.IOException;
|
27 |
| -import java.io.InputStreamReader; |
28 | 25 | import java.io.StringReader;
|
29 | 26 | import java.net.URL;
|
30 |
| -import java.nio.charset.StandardCharsets; |
31 | 27 | import java.nio.file.Files;
|
32 | 28 | import java.nio.file.Path;
|
33 | 29 | import java.time.Duration;
|
34 |
| -import java.util.Base64; |
35 | 30 | import java.util.LinkedList;
|
36 | 31 | import java.util.List;
|
37 | 32 | import java.util.Objects;
|
38 | 33 | import java.util.concurrent.ExecutorService;
|
39 | 34 | import java.util.concurrent.Executors;
|
40 |
| -import java.util.zip.ZipInputStream; |
41 | 35 | import org.junit.jupiter.api.AfterEach;
|
42 | 36 | import org.junit.jupiter.api.Assertions;
|
43 | 37 | import org.junit.jupiter.api.BeforeEach;
|
@@ -138,40 +132,15 @@ void canDownloadFiles() throws IOException {
|
138 | 132 |
|
139 | 133 | String fileName = ((HasDownloads) driver).getDownloadableFiles().get(0);
|
140 | 134 |
|
141 |
| - Path downloadLocation = Files.createTempDirectory("download"); |
142 |
| - ((HasDownloads) driver).downloadFile(fileName, downloadLocation); |
| 135 | + Path targetLocation = Files.createTempDirectory("download"); |
| 136 | + ((HasDownloads) driver).downloadFile(fileName, targetLocation); |
143 | 137 |
|
144 |
| - String fileContent = String.join("", Files.readAllLines(downloadLocation.resolve(fileName))); |
| 138 | + String fileContent = String.join("", Files.readAllLines(targetLocation.resolve(fileName))); |
145 | 139 | assertThat(fileContent).isEqualTo("Hello, World!");
|
146 | 140 |
|
147 | 141 | driver.quit();
|
148 | 142 | }
|
149 | 143 |
|
150 |
| - @Test |
151 |
| - void canUseDownloadedContent() throws IOException { |
152 |
| - URL gridUrl = server.getUrl(); |
153 |
| - WebDriver driver = new RemoteWebDriver(gridUrl, capabilities); |
154 |
| - driver = new Augmenter().augment(driver); |
155 |
| - |
156 |
| - driver.get(appServer.whereIs("downloads/download.html")); |
157 |
| - driver.findElement(By.id("file-1")).click(); |
158 |
| - |
159 |
| - new WebDriverWait(driver, Duration.ofSeconds(5)) |
160 |
| - .until(d -> !((HasDownloads) d).getDownloadableFiles().isEmpty()); |
161 |
| - |
162 |
| - String fileName = ((HasDownloads) driver).getDownloadableFiles().get(0); |
163 |
| - |
164 |
| - String base64Zip = ((HasDownloads) driver).downloadFile(fileName); |
165 |
| - byte[] decodedBytes = Base64.getDecoder().decode(base64Zip); |
166 |
| - ByteArrayInputStream bais = new ByteArrayInputStream(decodedBytes); |
167 |
| - try (ZipInputStream zis = new ZipInputStream(bais)) { |
168 |
| - zis.getNextEntry(); |
169 |
| - BufferedReader reader = |
170 |
| - new BufferedReader(new InputStreamReader(zis, StandardCharsets.UTF_8)); |
171 |
| - assertThat(reader.readLine()).isEqualTo("Hello, World!"); |
172 |
| - } |
173 |
| - } |
174 |
| - |
175 | 144 | @Test
|
176 | 145 | @Ignore(IE)
|
177 | 146 | @Ignore(SAFARI)
|
|
0 commit comments