From 8db1cb1bf891d66a0c472549a9c8946d251bb262 Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Wed, 10 Dec 2025 21:40:45 +0200 Subject: [PATCH 1/4] [temporarily] run only RemoteWebDriverDownloadTest to investigate it --- .github/workflows/ci-java.yml | 44 ---------------- .github/workflows/ci.yml | 50 ------------------- .../router/RemoteWebDriverDownloadTest.java | 8 ++- 3 files changed, 3 insertions(+), 99 deletions(-) diff --git a/.github/workflows/ci-java.yml b/.github/workflows/ci-java.yml index 63727764a0953..30c11c1010085 100644 --- a/.github/workflows/ci-java.yml +++ b/.github/workflows/ci-java.yml @@ -24,52 +24,8 @@ jobs: run: | fsutil 8dot3name set 0 bazel test --flaky_test_attempts 3 --pin_browsers=true //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest ` - //java/test/org/openqa/selenium/federatedcredentialmanagement:FederatedCredentialManagementTest ` //java/test/org/openqa/selenium/firefox:FirefoxDriverBuilderTest ` //java/test/org/openqa/selenium/grid/router:RemoteWebDriverDownloadTest ` //java/test/org/openqa/selenium/remote:RemoteWebDriverBuilderTest ` //java/test/org/openqa/selenium/grid/router:RemoteWebDriverDownloadTest ` //java/test/org/openqa/selenium/devtools:NetworkInterceptorRestTest - - browser-tests-macos: - name: Browser Tests - uses: ./.github/workflows/bazel.yml - strategy: - fail-fast: false - matrix: - include: - - os: macos - with: - name: Browser Tests (chrome, ${{ matrix.os }}) - os: ${{ matrix.os }} - browser: chrome - cache-key: java-${{ matrix.os }}-tests - # rules_jvm_external is not fully hermetic - # https://github.com/bazelbuild/rules_jvm_external/issues/1046 - java-version: 17 - run: | - bazel test --flaky_test_attempts 3 --pin_browsers=true //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest-remote \ - //java/test/org/openqa/selenium/federatedcredentialmanagement:FederatedCredentialManagementTest \ - //java/test/org/openqa/selenium/firefox:FirefoxDriverBuilderTest \ - //java/test/org/openqa/selenium/grid/router:RemoteWebDriverDownloadTest \ - //java/test/org/openqa/selenium/remote:RemoteWebDriverBuilderTest \ - //java/test/org/openqa/selenium/grid/router:RemoteWebDriverDownloadTest - - remote-tests: - name: Remote Tests - uses: ./.github/workflows/bazel.yml - strategy: - fail-fast: false - matrix: - include: - - os: macos - with: - name: Remote Tests (chrome, ${{ matrix.os }}) - os: ${{ matrix.os }} - browser: chrome - cache-key: java-${{ matrix.os }}-remote-tests - # rules_jvm_external is not fully hermetic - # https://github.com/bazelbuild/rules_jvm_external/issues/1046 - java-version: 17 - run: | - bazel test --flaky_test_attempts 3 --pin_browsers=true //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest-remote diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 287390546e2af..a37e529f69a2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,18 +45,6 @@ jobs: env: COMMIT_RANGE: ${{ github.event.pull_request.base.sha || github.event.before }}...${{ github.event.pull_request.head.sha || github.sha }} - dotnet: - name: .NET - needs: check - uses: ./.github/workflows/ci-dotnet.yml - if: > - github.event_name == 'schedule' || - github.event_name == 'workflow_dispatch' || - github.event_name == 'workflow_call' || - contains(needs.check.outputs.targets, '//dotnet') || - contains(join(github.event.commits.*.message), '[dotnet]') || - contains(github.event.pull_request.title, '[dotnet]') - java: name: Java needs: check @@ -68,41 +56,3 @@ jobs: contains(needs.check.outputs.targets, '//java') || contains(join(github.event.commits.*.message), '[java]') || contains(github.event.pull_request.title, '[java]') - - python: - name: Python - needs: check - uses: ./.github/workflows/ci-python.yml - if: > - github.event_name == 'schedule' || - github.event_name == 'workflow_dispatch' || - github.event_name == 'workflow_call' || - contains(needs.check.outputs.targets, '//py') || - contains(join(github.event.commits.*.message), '[py]') || - contains(github.event.pull_request.title, '[py]') - - ruby: - name: Ruby - needs: check - uses: ./.github/workflows/ci-ruby.yml - if: > - github.event_name == 'schedule' || - github.event_name == 'workflow_dispatch' || - github.event_name == 'workflow_call' || - contains(needs.check.outputs.targets, '//rb') || - contains(join(github.event.commits.*.message), '[rb]') || - contains(github.event.pull_request.title, '[rb]') - - rust: - name: Rust - needs: check - uses: ./.github/workflows/ci-rust.yml - secrets: - SELENIUM_CI_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }} - if: > - github.event_name == 'schedule' || - github.event_name == 'workflow_dispatch' || - github.event_name == 'workflow_call' || - contains(needs.check.outputs.targets, '//rust') || - contains(join(github.event.commits.*.message), '[rust]') || - contains(github.event.pull_request.title, '[rust]') diff --git a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java index df5aa945908a8..3434b9a08f95e 100644 --- a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java +++ b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java @@ -37,10 +37,8 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.stream.Collectors; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; + +import org.junit.jupiter.api.*; import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.environment.webserver.NettyAppServer; @@ -133,7 +131,7 @@ void canListDownloadedFiles() { driver.quit(); } - @Test + @RepeatedTest(20) @Ignore(IE) @Ignore(SAFARI) void canDownloadFiles() throws IOException { From b0a803278d62d1fb4357104e3dc9b36e4bd4a855 Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Wed, 10 Dec 2025 21:46:53 +0200 Subject: [PATCH 2/4] log the found files during download --- .../router/RemoteWebDriverDownloadTest.java | 81 +++++++++++++------ 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java index 3434b9a08f95e..72123a74cc3d8 100644 --- a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java +++ b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java @@ -17,6 +17,7 @@ package org.openqa.selenium.grid.router; +import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static org.openqa.selenium.HasDownloads.DownloadedFile; import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; @@ -36,8 +37,6 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.stream.Collectors; - import org.junit.jupiter.api.*; import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeOptions; @@ -98,7 +97,7 @@ public void tearDown() { executor.shutdownNow(); } - @Test + @RepeatedTest(10) @Ignore(IE) @Ignore(SAFARI) void canListDownloadedFiles() { @@ -111,27 +110,32 @@ void canListDownloadedFiles() { driver.findElement(By.id("file-2")).click(); HasDownloads hasDownloads = (HasDownloads) driver; - new WebDriverWait(driver, Duration.ofSeconds(5)) + new WebDriverWait(driver, Duration.ofSeconds(5), Duration.ofMillis(50)) .until( - d -> - hasDownloads.getDownloadableFiles().stream() - // ensure we hit no temporary file created by the browser while - // downloading - .filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith)) - .count() - == 2); + d -> { + List files = hasDownloads.getDownloadableFiles(); + List matchingFiles = + files.stream() + .filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith)) + .collect(toList()); + System.out.printf( + "[*****] FOUND %s FILES: %s; MATCHING %s FILES: %s%n", + files.size(), files, matchingFiles.size(), matchingFiles); + // ensure we hit no temporary file created by the browser while downloading + return matchingFiles.size() == 2; + }); List downloadableFiles = hasDownloads.getDownloadableFiles(); assertThat(downloadableFiles).contains("file_1.txt", "file_2.jpg"); List downloadedFiles = hasDownloads.getDownloadedFiles(); - assertThat(downloadedFiles.stream().map(f -> f.getName()).collect(Collectors.toList())) + assertThat(downloadedFiles.stream().map(f -> f.getName()).collect(toList())) .contains("file_1.txt", "file_2.jpg"); driver.quit(); } - @RepeatedTest(20) + @RepeatedTest(10) @Ignore(IE) @Ignore(SAFARI) void canDownloadFiles() throws IOException { @@ -142,20 +146,36 @@ void canDownloadFiles() throws IOException { driver.get(appServer.whereIs("downloads/download.html")); driver.findElement(By.id("file-1")).click(); - new WebDriverWait(driver, Duration.ofSeconds(5)) + new WebDriverWait(driver, Duration.ofSeconds(5), Duration.ofMillis(50)) .until( d -> - ((HasDownloads) d) - .getDownloadableFiles().stream() - // ensure we hit no temporary file created by the browser while downloading - .anyMatch((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith))); + { + List files = ((HasDownloads) d).getDownloadableFiles(); + List matchingFiles = files.stream() + .filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith)) + .collect(toList()); + System.out.printf( + "[*****] FOUND %s FILES: %s; MATCHING %s FILES: %s%n", + files.size(), files, matchingFiles.size(), matchingFiles); + + // ensure we hit no temporary file created by the browser while downloading + return !matchingFiles.isEmpty(); + }); DownloadedFile file = ((HasDownloads) driver).getDownloadedFiles().get(0); Path targetLocation = Files.createTempDirectory("download"); + System.out.printf( + "[*****] DOWNLOADING FILE %s (size: %s) into %s...%n", + file.getName(), file.getSize(), targetLocation.toAbsolutePath()); + ((HasDownloads) driver).downloadFile(file.getName(), targetLocation); File localFile = targetLocation.resolve(file.getName()).toFile(); + System.out.printf( + "[*****] DOWNLOADED FILE %s (size: %s) as %s (size: %s)...%n", + file.getName(), file.getSize(), localFile.getAbsolutePath(), localFile.length()); + assertThat(localFile).hasName(file.getName()); assertThat(localFile).hasSize(file.getSize()); assertThat(localFile).content().isEqualToIgnoringNewLines("Hello, World!"); @@ -175,16 +195,31 @@ void testCanDeleteFiles() { new WebDriverWait(driver, Duration.ofSeconds(5)) .until( d -> - ((HasDownloads) d) - .getDownloadableFiles().stream() - // ensure we hit no temporary file created by the browser while downloading - .anyMatch((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith))); + { + List files = ((HasDownloads) d).getDownloadableFiles(); + // ensure we hit no temporary file created by the browser while downloading + List matchingFiles = files.stream() + .filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith)) + .collect(toList()); + + System.out.printf( + "[*****] FOUND %s FILES: %s; MATCHING %s FILES: %s%n", + files.size(), files, matchingFiles.size(), matchingFiles); + return !matchingFiles.isEmpty(); + }); + + System.out.printf("[*****] Augmenting webdriver...%n"); driver = new Augmenter().augment(driver); + + System.out.printf("[*****] Deleting all downloaded files...%n"); ((HasDownloads) driver).deleteDownloadableFiles(); List afterDeleteNames = ((HasDownloads) driver).getDownloadableFiles(); - assertThat(afterDeleteNames.isEmpty()).isTrue(); + System.out.printf( + "[*****] FOUND %s DOWNLOADED FILES: %s%n", + afterDeleteNames.size(), afterDeleteNames); + assertThat(afterDeleteNames).isEmpty(); driver.quit(); } From 1b002bf169581fbe29d4acbaa572d68ec2acd94d Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Thu, 11 Dec 2025 21:19:07 +0200 Subject: [PATCH 3/4] reformat the code --- .../selenium/grid/node/local/LocalNode.java | 8 +--- .../router/RemoteWebDriverDownloadTest.java | 42 +++++++++---------- 2 files changed, 22 insertions(+), 28 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 de0ae01760e9e..d4dbb3e1f8753 100644 --- a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java @@ -59,13 +59,7 @@ import java.time.Duration; import java.time.Instant; import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; diff --git a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java index 72123a74cc3d8..d5a9c5ef1587c 100644 --- a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java +++ b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java @@ -92,9 +92,10 @@ public void setupServers() { } @AfterEach - public void tearDown() { + public void tearDown() throws InterruptedException { tearDowns.parallelStream().forEach(Safely::safelyCall); executor.shutdownNow(); +// executor.awaitTermination(10, SECONDS); } @RepeatedTest(10) @@ -148,15 +149,15 @@ void canDownloadFiles() throws IOException { new WebDriverWait(driver, Duration.ofSeconds(5), Duration.ofMillis(50)) .until( - d -> - { + d -> { List files = ((HasDownloads) d).getDownloadableFiles(); - List matchingFiles = files.stream() - .filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith)) - .collect(toList()); + List matchingFiles = + files.stream() + .filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith)) + .collect(toList()); System.out.printf( - "[*****] FOUND %s FILES: %s; MATCHING %s FILES: %s%n", - files.size(), files, matchingFiles.size(), matchingFiles); + "[*****] FOUND %s FILES: %s; MATCHING %s FILES: %s%n", + files.size(), files, matchingFiles.size(), matchingFiles); // ensure we hit no temporary file created by the browser while downloading return !matchingFiles.isEmpty(); @@ -166,15 +167,15 @@ void canDownloadFiles() throws IOException { Path targetLocation = Files.createTempDirectory("download"); System.out.printf( - "[*****] DOWNLOADING FILE %s (size: %s) into %s...%n", - file.getName(), file.getSize(), targetLocation.toAbsolutePath()); + "[*****] DOWNLOADING FILE %s (size: %s) into %s...%n", + file.getName(), file.getSize(), targetLocation.toAbsolutePath()); ((HasDownloads) driver).downloadFile(file.getName(), targetLocation); File localFile = targetLocation.resolve(file.getName()).toFile(); System.out.printf( - "[*****] DOWNLOADED FILE %s (size: %s) as %s (size: %s)...%n", - file.getName(), file.getSize(), localFile.getAbsolutePath(), localFile.length()); + "[*****] DOWNLOADED FILE %s (size: %s) as %s (size: %s)...%n", + file.getName(), file.getSize(), localFile.getAbsolutePath(), localFile.length()); assertThat(localFile).hasName(file.getName()); assertThat(localFile).hasSize(file.getSize()); @@ -194,17 +195,17 @@ void testCanDeleteFiles() { new WebDriverWait(driver, Duration.ofSeconds(5)) .until( - d -> - { + d -> { List files = ((HasDownloads) d).getDownloadableFiles(); // ensure we hit no temporary file created by the browser while downloading - List matchingFiles = files.stream() - .filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith)) - .collect(toList()); + List matchingFiles = + files.stream() + .filter((f) -> FILE_EXTENSIONS.stream().anyMatch(f::endsWith)) + .collect(toList()); System.out.printf( - "[*****] FOUND %s FILES: %s; MATCHING %s FILES: %s%n", - files.size(), files, matchingFiles.size(), matchingFiles); + "[*****] FOUND %s FILES: %s; MATCHING %s FILES: %s%n", + files.size(), files, matchingFiles.size(), matchingFiles); return !matchingFiles.isEmpty(); }); @@ -217,8 +218,7 @@ void testCanDeleteFiles() { List afterDeleteNames = ((HasDownloads) driver).getDownloadableFiles(); System.out.printf( - "[*****] FOUND %s DOWNLOADED FILES: %s%n", - afterDeleteNames.size(), afterDeleteNames); + "[*****] FOUND %s DOWNLOADED FILES: %s%n", afterDeleteNames.size(), afterDeleteNames); assertThat(afterDeleteNames).isEmpty(); driver.quit(); From 9291893bff434052b70e7b38940bc041c00d3cb6 Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Fri, 12 Dec 2025 00:11:00 +0200 Subject: [PATCH 4/4] reformat the code --- .../selenium/grid/router/RemoteWebDriverDownloadTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java index d5a9c5ef1587c..8e00d9fa26331 100644 --- a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java +++ b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java @@ -95,7 +95,7 @@ public void setupServers() { public void tearDown() throws InterruptedException { tearDowns.parallelStream().forEach(Safely::safelyCall); executor.shutdownNow(); -// executor.awaitTermination(10, SECONDS); + // executor.awaitTermination(10, SECONDS); } @RepeatedTest(10)