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.
Narrative documentation:
API documentation:
Please read CONTRIBUTING.md before submitting your pull requests.
- Bazelisk, a Bazel wrapper that automatically downloads
the version of Bazel specified in
.bazelversion
file and transparently passes through all command-line arguments to the real Bazel binary. - The latest version of the Java 11 OpenJDK
java
andjar
on the$PATH
(make sure you usejava
executable 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+ and
python
on thePATH
- Ruby 3+ and
ruby
on thePATH
- The tox automation project for Python:
pip install tox
- macOS users:
- Install the latest version of Xcode including the command-line tools. This command should work
xcode-select --install
- Apple Silicon Macs should add
build --host_platform=//:rosetta
to their.bazelrc.local
file. We are working to make sure this isn't required in the long run.
- Install the latest version of Xcode including the command-line tools. This command should work
- Windows users:
- Latest version of Visual Studio with command line tools and build tools installed
BAZEL_VS
environment variable should point to the location of the build tools, e.g.C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
BAZEL_VC
environment 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_VERSION
environment variable should contain the version of the installed command line tools, e.g.14.27.29110
- A detailed setup guide can be seen on Jim Evan's post
- If the Jim's blog instructions were followed, also make sure
C:\tools\msys65\usr\bin
is on thePATH
.
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.
More detailed instructions for getting Bazel running are below, but if you can successfully get the java and javascript folders to build without errors, you should be confident that you have the correct binaries on your system.
Ensure that you have Firefox installed and the latest
geckodriver
on your $PATH
.
You may have to update this from time to time.
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>
The 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.
The 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 Grid deployment jar, run this command:
bazel build grid
The log will show where the output jar is located.
Click to see JavaScript Build Steps
If you want to build all the JavaScript code you can run:
bazel build javascript/...
To build the NodeJS bindings you will need to run:
bazel build //javascript/node/selenium-webdriver
To run the tests run:
bazel test //javascript/node/selenium-webdriver:tests
You can pass in the environment variable SELENIUM_BROWSER
with the name of the browser.
To publish to NPM run:
bazel run //javascript/node/selenium-webdriver:selenium-webdriver.publish
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 install locally run:
bazel build //py:selenium-wheel
pip install bazel-bin/py/selenium-*.whl
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/...
Also
bazel build //dotnet/test/common:chrome