From 9ca307a253372be817e929529e21954ce65fdce5 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Fri, 4 Sep 2026 18:49:05 +0200 Subject: [PATCH 1/2] [java] remove deprecated GET /session/{sessionId}/se/files/{fileName} endpoint Marked @Deprecated in #16844 (Jan 2026) with a note to remove it in Selenium 4.41, 4.42, or 4.43. Trunk is now at 4.49.0-SNAPSHOT, six releases past that target, and none of the four client bindings ever built a request to this path -- they only use the list/POST/DELETE forms of /se/files. --- .../org/openqa/selenium/grid/node/Node.java | 3 --- .../selenium/grid/node/local/LocalNode.java | 20 ------------------- .../openqa/selenium/remote/DriverCommand.java | 10 ---------- .../codec/AbstractHttpCommandCodec.java | 2 -- .../grid/node/local/LocalNodeTest.java | 9 --------- 5 files changed, 44 deletions(-) diff --git a/java/src/org/openqa/selenium/grid/node/Node.java b/java/src/org/openqa/selenium/grid/node/Node.java index 8171a0f753d75..efd16c75f0bde 100644 --- a/java/src/org/openqa/selenium/grid/node/Node.java +++ b/java/src/org/openqa/selenium/grid/node/Node.java @@ -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")), post("/session/{sessionId}/se/files") .to(params -> new DownloadFile(this, sessionIdFrom(params))) .with(spanDecorator("node.download_file")), diff --git a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java index bb5576a6c9c5e..cd9a22720eecc 100644 --- a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java @@ -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); } @@ -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[] {}); diff --git a/java/src/org/openqa/selenium/remote/DriverCommand.java b/java/src/org/openqa/selenium/remote/DriverCommand.java index 56365f8e74428..9ab943f5ebbfa 100644 --- a/java/src/org/openqa/selenium/remote/DriverCommand.java +++ b/java/src/org/openqa/selenium/remote/DriverCommand.java @@ -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). - * - *

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"; diff --git a/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java b/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java index dd16eb6ea578a..42e5d36d1d065 100644 --- a/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java +++ b/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java @@ -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; @@ -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")); diff --git a/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java b/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java index a3ccfd06f63bb..26b0f534597ff 100644 --- a/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java +++ b/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java @@ -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(); From 37dab4a2ec3c84623ed6da8a7e6da4151f3fad55 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Fri, 4 Sep 2026 19:43:04 +0200 Subject: [PATCH 2/2] [java] remove now-dead getDownloadedFile(File, String) overload Spotbugs flagged it as an unused private method after the prior commit removed the deprecated GET /se/files/{fileName} endpoint, which was its only caller. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_014kEM1tVUYCgzyhJ5xmseyF --- .../openqa/selenium/grid/node/local/LocalNode.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java index cd9a22720eecc..8041b97fc74b5 100644 --- a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java @@ -1017,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()