Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions java/src/org/openqa/selenium/grid/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ protected Node(
get("/session/{sessionId}/se/files")
.to(params -> new DownloadFile(this, sessionIdFrom(params)))
.with(spanDecorator("node.download_file")),
get("/session/{sessionId}/se/files/{fileName}")
.to(params -> new DownloadFile(this, sessionIdFrom(params)))
.with(spanDecorator("node.download_file")),
Comment thread
diemol marked this conversation as resolved.
post("/session/{sessionId}/se/files")
.to(params -> new DownloadFile(this, sessionIdFrom(params)))
.with(spanDecorator("node.download_file")),
Expand Down
31 changes: 0 additions & 31 deletions java/src/org/openqa/selenium/grid/node/local/LocalNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,6 @@ public HttpResponse downloadFile(HttpRequest req, SessionId id) {
if (req.getMethod().equals(HttpMethod.GET) && req.getUri().endsWith("/se/files")) {
return listDownloadedFiles(downloadsDirectory);
}
if (req.getMethod().equals(HttpMethod.GET)) {
// Left here for backward compatibility.
// Remove this IF in Selenium 4.41, 4.42 or 4.43
return getDownloadedFile(downloadsDirectory, extractFileName(req));
}
if (req.getMethod().equals(HttpMethod.DELETE)) {
return deleteDownloadedFile(downloadsDirectory);
}
Expand All @@ -945,21 +940,6 @@ public HttpResponse downloadFile(HttpRequest req, SessionId id) {
}
}

private String extractFileName(HttpRequest req) {
return extractFileName(req.getUri());
}

String extractFileName(String uri) {
String prefix = "/se/files/";
int index = uri.lastIndexOf(prefix);
if (index < 0) {
throw new IllegalArgumentException("Unexpected URL for downloading a file: " + uri);
}
// The server has already decoded the path of the request, so the file name needs no
// further processing to match the name of the file on disk.
return uri.substring(index + prefix.length());
}

/** User wants to list files that can be downloaded */
private HttpResponse listDownloadedFiles(File downloadsDirectory) {
File[] files = Optional.ofNullable(downloadsDirectory.listFiles()).orElse(new File[] {});
Expand Down Expand Up @@ -1037,17 +1017,6 @@ private HttpResponse getDownloadedFile(HttpRequest req, File downloadsDirectory)
return new HttpResponse().setContent(asJson(result));
}

/** Left here for backward compatibility. Remove this method in Selenium 4.41, 4.42 or 4.43 */
@Deprecated
private HttpResponse getDownloadedFile(File downloadsDirectory, String fileName)
throws IOException {
if (fileName.isEmpty()) {
throw new WebDriverException("Please specify file to download in URL");
}
File file = findDownloadedFile(downloadsDirectory, fileName);
return fileAsBinaryResponse(file);
}

private HttpResponse fileAsBinaryResponse(File file) throws IOException {
BasicFileAttributes attributes = readAttributes(file.toPath(), BasicFileAttributes.class);
return new HttpResponse()
Expand Down
10 changes: 0 additions & 10 deletions java/src/org/openqa/selenium/remote/DriverCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,6 @@ public interface DriverCommand {
String GET_DOWNLOADABLE_FILES = "getDownloadableFiles";
String DOWNLOAD_FILE = "downloadFile";

/**
* This endpoint was introduced in 4.39.0, but not used anymore since 4.40.0. Left here for
* backward compatibility (if someone uses Grid 4.40+, but Client 4.39.0).
*
* <p>Remove it in 4.41, 4.42 or 4.43.
*
* @deprecated use {@link #DOWNLOAD_FILE} instead
*/
@Deprecated String GET_DOWNLOADED_FILE = "getDownloadedFile";

String DELETE_DOWNLOADABLE_FILES = "deleteDownloadableFiles";

String FIRE_SESSION_EVENT = "fireSessionEvent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import static org.openqa.selenium.remote.DriverCommand.GET_CREDENTIALS;
import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_URL;
import static org.openqa.selenium.remote.DriverCommand.GET_DOWNLOADABLE_FILES;
import static org.openqa.selenium.remote.DriverCommand.GET_DOWNLOADED_FILE;
import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_RECT;
import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_TAG_NAME;
import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_TEXT;
Expand Down Expand Up @@ -202,7 +201,6 @@ public AbstractHttpCommandCodec() {

defineCommand(GET_DOWNLOADABLE_FILES, get(sessionId + "/se/files"));
defineCommand(DOWNLOAD_FILE, post(sessionId + "/se/files"));
defineCommand(GET_DOWNLOADED_FILE, get(sessionId + "/se/files/:name"));
defineCommand(DELETE_DOWNLOADABLE_FILES, delete(sessionId + "/se/files"));

defineCommand(FIRE_SESSION_EVENT, post(sessionId + "/se/event"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,6 @@ void bidiIsDisabledAndResponseCapsShowThat() throws URISyntaxException {
assertThat(Boolean.parseBoolean(bidiEnabled.toString())).isFalse();
}

@Test
void extractsFileNameFromRequestUri() {
assertThat(node.extractFileName("/session/1234/se/files/logo.png")).isEqualTo("logo.png");
assertThat(node.extractFileName("/session/1234/se/files/файл+with+tähtedega.png"))
.isEqualTo("файл+with+tähtedega.png");
assertThat(node.extractFileName("/session/1234/se/files/attestation pour l'employeur.pdf"))
.isEqualTo("attestation pour l'employeur.pdf");
}

@Test
void commandInterceptorIsCalledForEachWebDriverCommand() throws URISyntaxException {
Tracer tracer = DefaultTestTracer.createTracer();
Expand Down