Selenium is an umbrella project encapsulating a variety of tools and libraries enabling web browser automation. Selenium specifically provides an infrastructure for the W3C WebDriver specification — a platform and language-neutral coding interface compatible with all major web browsers.
The project is made possible by volunteer contributors who've generously donated thousands of hours in code development and upkeep.
Selenium's source code is made available under the Apache 2.0 license.
Please read CONTRIBUTING.md before submitting your pull requests.
Bazelisk, a Bazel wrapper that automatically downloads
the version of Bazel specified in
.bazelversionfile and transparently passes through all command-line arguments to the real Bazel binary.
- The latest version of the Java 11 OpenJDK
jaron the PATH (make sure you use
javaexecutable from JDK but not JRE).
- To test this, try running the command
javac. This command won't exist if you only have the JRE installed. If you're met with a list of command-line options, you're referencing the JDK properly.
- To test this, try running the command
- Python 3.7+
pythonon the PATH
The tox automation project for Python:
pip install tox
- MacOS users should have the latest version of Xcode installed, including the command-line tools. The following command should work:
Users of Apple Silicon Macs should add
build --host_platform=//:rosettato their
.bazelrc.localfile. We are working to make sure this isn't required in the long run.
Windows users should have the latest version of Visual Studio command line tools and build tools installed
BAZEL_VSenvironment variable should point to the location of the build tools, e.g.
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
BAZEL_VCenvironment variable should point to the location of the command line tools, e.g.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC
BAZEL_VC_FULL_VERSIONenvironment variable should contain the version of the installed command line tools, e.g.
- Ruby 2.0
Internet Explorer Driver
If you plan to compile the IE driver, you also need:
- Visual Studio 2008
- 32 and 64-bit cross compilers
The build will work on any platform, but the tests for IE will be skipped silently if you are not building on Windows.
Bazel was built by the fine folks at Google. Bazel manages dependency downloads, generates the Selenium binaries, executes tests, and does it all rather quickly.
Ensure that you have Firefox installed and the latest
geckodriver on your
You may have to update this from time to time.
Common Build Targets
Click to see Java Build Steps
To build the most commonly-used modules of Selenium from source, execute this command from the root project folder:
bazel build java/...
If you want to test you can run then you can do so by running the following command
bazel test //java/... --test_size_filters=small,medium,large --test_tag_filters=<browser>
test_size_filters argument takes small, medium, large. Small are akin to unit tests,
medium is akin to integration tests, and large is akin to end to end tests.
test_tag_filters allow us to pass in browser names and a few different tags that we can
find in the code base.
To build the NodeJS bindings you will need to run:
To run the tests run:
You can pass in the environment variable
SELENIUM_BROWSER with the name of the browser.
To publish to NPM run:
Click to see Python Build Steps
If you want to build the python bindings run:
bazel build //py:selenium
To run the tests run:
bazel test //py:test-<browsername>
If you add
--//common:pin_browsers it will download the browsers and drivers for you to use.
To publish run
bazel build //py:selenium-wheel twine upload bazel-bin/py/selenium-*.whl
Click to see Ruby Build Steps
To build the Ruby code run:
bazel build //rb/...
Click to see .NET Build Steps
To build the .NET code run:
bazel build //dotnet/...
- Bazel files are called BUILD.bazel
- crazyfun build files are called build.desc. This is an older build system, still in use in the project for Ruby bindings mostly.
The order the modules are built is determined by the build system. If you want to build an individual module (assuming all dependent modules have previously been built), try the following:
In this case,
test is a target in that directory's
As you see build targets scroll past in the log, you may want to run them individually.
Common Tasks (Bazel)
To build the bulk of the Selenium binaries from source, run the following command from the root folder:
To build the grid deployment jar, run this command:
bazel build grid
To run tests within a particular area of the project, use the "test" command, followed
by the folder or target. Tests are tagged with "small", "medium", or "large", and can be filtered
bazel test --test_size_filters=small,medium java/...
Bazel's "test" command will run all tests in the package, including integration tests. Expect
test java/... to launch browsers and consume a considerable amount of time and resources.
To bump the versions of the pinned browsers to their latest stable versions:
bazel run scripts:pinned_browsers > temp.bzl && mv temp.bzl common/repositories.bzl
Most of the team use either Intellij IDEA or VS.Code for their day-to-day editing. If you're working in IntelliJ, then we highly recommend installing the Bazel IJ plugin which is documented on its own site.
If you do use IntelliJ and the Bazel plugin, there is a project view checked into the tree in scripts/ij.bazelproject which will make it easier to get up running, and editing code :)
bazel run debug-server
Now, navigate to
You'll find the contents of the
We use the Closure
The tests in this directory are normal HTML files with names ending
_test.html. Click on one to load the page and run the test.
Maven POM files
Here is the public Selenium Maven repository.
bazel makes a top-level group of directories with the
bazel- prefix on each directory.
More general, but basic, help for
go is just a wrapper around
Rake, so you can use the standard
commands such as
rake -T to get more information about available
Maven per se
If it is not clear already, Selenium is not built with Maven. It is
bazel, though that is invoked with
go as outlined above,
so you do not have to learn too much about that.
That said, it is possible to relatively quickly build Selenium pieces
for Maven to use. You are only really going to want to do this when
you are testing the cutting-edge of Selenium development (which we
welcome) against your application. Here is the quickest way to build
and deploy into your local maven repository (
skipping Selenium's own tests.
The maven jars should now be in your local
Refer to the Build Instructions wiki page for the last word on building the bits and pieces of Selenium.
Running Browser Tests on Linux
By default, Bazel runs these tests in your current X-server UI. If you prefer, you can alternatively run them in a virtual or nested X-server.
- Run the X server
- Run a window manager, for example,
- Run the tests you are interested in:
bazel test --test_env=DISPLAY=:99 //java/... --test_tag_filters=chrome
An easy way to run tests in a virtual X-server is to use Bazel's
bazel test --run_under="xvfb-run -a" //java/... --test_tag_filters=chrome
Selenium Build Docker Image
If you're finding it hard to set up a development environment using bazel and you have access to Docker, then you can build a Docker image suitable for building and testing Selenium in from the Dockerfile in the dev image directory.
Bazelisk is a Mac-friendly launcher for Bazel. To install, follow these steps:
brew tap bazelbuild/tap && \ brew uninstall bazel; \ brew install bazelbuild/tap/bazelisk
If you're getting errors that mention Xcode, you'll need to install the command-line tools.
Bazel for Mac requires some additional steps to configure properly. First things first: use the Bazelisk project (courtesy of philwo), a pure golang implementation of Bazel. In order to install Bazelisk, first verify that your Xcode will cooperate: execute the following command:
If the value is
/Applications/Xcode.app/Contents/Developer/, you can proceed with bazelisk
installation. If, however, the return value is
need to redirect the Xcode system to the correct value.
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/ sudo xcodebuild -license
The first command will prompt you for a password. The second step requires you to read a new Xcode license, and then accept it by typing "agree".
(Thanks to this thread for these steps)
Begin by tagging the revision you're about to release, and push that tag to GitHub.
Before running a release build, you must ensure that the
--stamp flag is used by
the build. The easiest way to do this is:
echo build --stamp >>.bazelrc.local
GitHub Release Page
- Draft a new (perhaps pre-release)
- Make sure this release is for the tag you created earlier
- Set the title to be whatever the release is.
git log $PREV_RELEASE..$NEW_TAG --format=format:'* [%h
](https://github.com/seleniumhq/selenium/commit/%H) - %s :: %an' | pbcopyto generate the list of changes. Make sure you've set
- The release notes are:
- Now publish the release.
To release the Java components, make sure you have permission to push to the OSS Sonatype repo. You will need these credentials when pushing the maven release.
Make sure that the java
CHANGELOG is up to date, then just run:
This will do two things:
- Build the publishable artifacts and push them to a staging repo on the OSS Sonatype server.
- Create zip files to upload in
You will need to manually release the maven artifacts, and also upload
the artifacts from
build/dist to the GitHub release.