Skip to content
Draft
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
44 changes: 0 additions & 44 deletions .github/workflows/ci-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
50 changes: 0 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]')
8 changes: 1 addition & 7 deletions java/src/org/openqa/selenium/grid/node/local/LocalNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,11 +37,7 @@
import java.util.Set;
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;
Expand Down Expand Up @@ -95,12 +92,13 @@ public void setupServers() {
}

@AfterEach
public void tearDown() {
public void tearDown() throws InterruptedException {
tearDowns.parallelStream().forEach(Safely::safelyCall);
executor.shutdownNow();
// executor.awaitTermination(10, SECONDS);
}

@Test
@RepeatedTest(10)
@Ignore(IE)
@Ignore(SAFARI)
void canListDownloadedFiles() {
Expand All @@ -113,27 +111,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<String> files = hasDownloads.getDownloadableFiles();
List<String> 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<String> downloadableFiles = hasDownloads.getDownloadableFiles();
assertThat(downloadableFiles).contains("file_1.txt", "file_2.jpg");

List<DownloadedFile> 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();
}

@Test
@RepeatedTest(10)
@Ignore(IE)
@Ignore(SAFARI)
void canDownloadFiles() throws IOException {
Expand All @@ -144,20 +147,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)));
d -> {
List<String> files = ((HasDownloads) d).getDownloadableFiles();
List<String> 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!");
Expand All @@ -176,17 +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)));

d -> {
List<String> files = ((HasDownloads) d).getDownloadableFiles();
// ensure we hit no temporary file created by the browser while downloading
List<String> 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<String> 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();
}
Expand Down