Implementation:SeleniumHQ Selenium Bazel Test With Filters
| Knowledge Sources | |
|---|---|
| Domains | Testing, Continuous_Integration, Quality_Assurance |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
External tool documentation for running Selenium tests using Bazel with size and tag filters.
Description
bazel test with --test_size_filters and --test_tag_filters enables targeted test execution across the polyglot monorepo. Each language binding has its own test structure and targets. Important: if multiple --test_tag_filters flags are specified, only the last one is used -- be careful when inheriting from configs. .NET tests currently require pinned browsers. Ruby tests have granular target naming matching spec file names with browser and remote suffixes.
Usage
Run tests after building to verify changes. Start with unit tests for fast feedback, then run browser-specific tests for integration verification. Verify that both new and existing tests pass locally before pushing code.
Code Reference
Source Location
- Repository: Selenium
- File: README.md (L293-545)
- File: CONTRIBUTING.md (L212-294)
Signature
# General test command pattern
bazel test //<language>/... [--test_size_filters=SIZE] [--test_tag_filters=TAGS]
Import
N/A - External test runner commands
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| target | Bazel label | Yes | Test target (e.g., //java/..., //py:unit, //rb/spec/unit/...) |
| --test_size_filters | String | No | Comma-separated: small, medium, large |
| --test_tag_filters | String | No | Comma-separated include/exclude tags (prefix with - to exclude) |
| --pin_browsers | Flag | No | Use pinned browser versions (default) vs Selenium Manager |
| --headless | Flag | No | Run browsers in headless mode (Chrome, Edge, Firefox) |
| --test_output | String | No | all (show everything), streamed (real-time), errors (default) |
| --cache_test_results | Boolean | No | no or -t- to disable caching and force re-run |
| --flaky_test_attempts | Integer | No | Number of retry attempts for flaky tests |
| --local_test_jobs | Integer | No | Parallelism level for test execution |
| --test_env | String | No | Environment variable to pass (e.g., SELENIUM_BROWSER=firefox) |
| --run_under | String | No | Command prefix (e.g., "xvfb-run -a" for virtual display) |
Outputs
| Name | Type | Description |
|---|---|---|
| Test results | Pass/Fail | Per-test pass/fail status with optional console output |
| Test log | File | Detailed log at bazel-testlogs/<target>/test.log |
Usage Examples
Java
# Unit tests
bazel test //java/... --test_size_filters=small
# Integration tests
bazel test //java/... --test_size_filters=medium
# Browser tests (Chrome)
bazel test //java/... --test_size_filters=large --test_tag_filters=chrome
# Specific test class
bazel test //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest
# Small + medium tests, excluding browser tests
bazel test --test_size_filters=small,medium --cache_test_results=no \
--test_tag_filters=-browser-test //java/...
Python
# Unit tests
bazel test //py:unit
# Browser tests
bazel test //py:test-chrome
bazel test //py:test-firefox
# BiDi tests
bazel test //py:test-chrome-bidi
# Headless
bazel test //py:test-chrome --//common:headless=true
# All Python tests
bazel test //py:all
Ruby
# All Ruby tests + lint
bazel test //rb/...
# Unit tests only
bazel test //rb/spec/unit/...
# Or:
bazel test //rb/spec/... --test_size_filters=small
# Integration tests for specific browser
bazel test //rb/spec/integration/... --test_tag_filters=firefox
# Remote browser tests
bazel test //rb/spec/integration/... --test_tag_filters=firefox-remote
# Specific test (target name = spec file without _spec.rb)
bazel test //rb/spec/unit/selenium/webdriver:proxy
# Filter specs by name
bazel test //rb/spec/integration/selenium/webdriver:driver-chrome \
--test_arg="-eTimeouts"
# Run linter
bazel test //rb:lint
JavaScript
# All JS tests
bazel test //javascript/selenium-webdriver:all
# With specific browser
bazel test //javascript/selenium-webdriver:all \
--test_env=SELENIUM_BROWSER=firefox
.NET
# All .NET tests (requires pinned browsers)
bazel test //dotnet/test/common:AllTests
# Specific test class
bazel test //dotnet/test/common:ElementFindingTest
# Specific browser
bazel test //dotnet/test/common:ElementFindingTest-edge
Rust
bazel test //rust/...
Linux Virtual Display
# Option 1: Run under xvfb
bazel test --run_under="xvfb-run -a" //java/... --test_tag_filters=chrome
# Option 2: Manual X server
Xvfb :99 &
DISPLAY=:99 jwm &
bazel test --test_env=DISPLAY=:99 //java/... --test_tag_filters=chrome