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
1 change: 1 addition & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SE_CACHE_PATH: $RUNNER_TEMP/selenium
steps:
- name: Checkout source tree
uses: actions/checkout@v4
Expand Down
109 changes: 49 additions & 60 deletions .github/workflows/ci-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,68 @@ name: CI - Java

on:
workflow_call:
inputs:
targets:
required: false
type: string
default: ''
run-full-suite:
required: false
type: boolean
default: true
workflow_dispatch:

permissions:
contents: read

jobs:
browser-tests-windows:
name: Browser Tests
uses: ./.github/workflows/bazel.yml
strategy:
fail-fast: false
matrix:
include:
- os: windows
with:
name: Browser Tests (chrome, ${{ matrix.os }})
os: ${{ matrix.os }}
browser: chrome
# rules_jvm_external is not fully hermetic
# https://github.com/bazelbuild/rules_jvm_external/issues/1046
java-version: 17
rerun-with-debug: true
run: >
bazel test --flaky_test_attempts 2
//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
filter-targets:
name: Filter Targets
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.filter.outputs.targets }}
steps:
- name: Filter Java targets
id: filter
shell: bash
run: |
targets="${{ inputs.targets }}"
filtered=()

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
# rules_jvm_external is not fully hermetic
# https://github.com/bazelbuild/rules_jvm_external/issues/1046
java-version: 17
rerun-with-debug: true
run: >
bazel test --flaky_test_attempts 2
//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
for t in $targets; do
[[ "$t" == //java/* ]] && filtered+=("$t")
done

remote-tests:
name: Remote Tests
if [ ${#filtered[@]} -eq 0 ]; then
echo "targets=//java/..." >> "$GITHUB_OUTPUT"
else
echo "targets=${filtered[*]}" >> "$GITHUB_OUTPUT"
fi

browser-tests:
name: Browser Tests
needs: filter-targets
uses: ./.github/workflows/bazel.yml
strategy:
fail-fast: false
matrix:
include:
- os: macos
os: [windows, macos]
browser: [chrome, firefox-beta, edge]
run_type: [driver, grid]
with:
name: Remote Tests (chrome, ${{ matrix.os }})
name: Browser Tests (${{ matrix.os }} - ${{ matrix.browser }} - ${{ matrix.run_type }})
os: ${{ matrix.os }}
browser: chrome
# rules_jvm_external is not fully hermetic
# https://github.com/bazelbuild/rules_jvm_external/issues/1046
java-version: 17
browser: ${{ matrix.browser }}
rerun-with-debug: true
run: >
bazel test --flaky_test_attempts 2
//java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest-remote
bazel test
--keep_going
--build_tests_only
--flaky_test_attempts 2
--local_test_jobs 1
--test_size_filters=large
--test_tag_filters="${{ matrix.run_type == 'grid' && format('{0}-remote', matrix.browser) || format('{0},-remote', matrix.browser) }}"
--pin_browsers=false
--test_env=SE_FORCE_BROWSER_DOWNLOAD=true
--test_env=SE_SKIP_DRIVER_IN_PATH=true
${{ needs.filter-targets.outputs.targets }}
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ jobs:
name: Java
needs: check
uses: ./.github/workflows/ci-java.yml
with:
targets: ${{ needs.check.outputs.targets }}
run-full-suite: >-
${{
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'workflow_call' ||
contains(github.event.pull_request.title, '[java]')
}}
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'workflow_call' ||
contains(needs.check.outputs.targets, '//java') ||
contains(join(github.event.commits.*.message), '[java]') ||
contains(github.event.pull_request.title, '[java]')

python:
Expand Down
2 changes: 1 addition & 1 deletion java/private/selenium_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def selenium_test(name, test_class, size = "medium", browsers = DEFAULT_BROWSERS
"-Dselenium.browser.remote=true",
],
# No need to lint remote tests as the code for non-remote is the same and they get linted
tags = BROWSERS[browser]["tags"] + tags + ["remote-browser", "no-lint"],
tags = BROWSERS[browser]["tags"] + tags + ["remote", "%s-remote" % browser, "no-lint"],
data = BROWSERS[browser]["data"] + data + [
"@selenium//java/src/org/openqa/selenium/grid:selenium_server",
],
Expand Down
4 changes: 4 additions & 0 deletions java/test/org/openqa/selenium/FrameSwitchingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.openqa.selenium.support.ui.ExpectedConditions.frameToBeAvailableAndSwitchToIt;
import static org.openqa.selenium.support.ui.ExpectedConditions.not;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;
Expand All @@ -36,6 +37,7 @@
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.JupiterTestBase;
import org.openqa.selenium.testing.NotYetImplemented;
import org.openqa.selenium.testing.TestUtilities;

class FrameSwitchingTest extends JupiterTestBase {

Expand Down Expand Up @@ -499,6 +501,8 @@ void testJavaScriptShouldExecuteInTheContextOfTheCurrentFrame() {

@Test
void testShouldNotSwitchMagicallyToTheTopWindow() {
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(Platform.MAC));

String baseUrl = appServer.whereIs("frame_switching_tests/");
driver.get(baseUrl + "bug4876.html");
driver.switchTo().frame(0);
Expand Down
34 changes: 34 additions & 0 deletions java/test/org/openqa/selenium/WaitingConditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,40 @@ public String toString() {
};
}

public static ExpectedCondition<Boolean> windowSizeEqual(final Dimension size) {
return new ExpectedCondition<>() {
private Dimension last;

@Override
public Boolean apply(WebDriver driver) {
last = driver.manage().window().getSize();
return last.height == size.height && last.width == size.width;
}

@Override
public String toString() {
return String.format("window size to be %s but was %s", size, last);
}
};
}

public static ExpectedCondition<Boolean> windowPositionEqual(final Point position) {
return new ExpectedCondition<>() {
private Point last;

@Override
public Boolean apply(WebDriver driver) {
last = driver.manage().window().getPosition();
return last.equals(position);
}

@Override
public String toString() {
return String.format("window position to be %s but was %s", position, last);
}
};
}

public static ExpectedCondition<Set<String>> windowHandleCountToBe(
final int expectedWindowCount) {
return new ExpectedCondition<>() {
Expand Down
Loading
Loading