<a href="https://selenium.dev"><img src="common/images/selenium_logo_mark_green.svg" width="180" alt="Selenium Logo"/></a>
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.
This README is for developers interested in contributing to the project. For people looking to get started using Selenium, please check out our User Manual for detailed examples and descriptions, and if you get stuck, there are several ways to Get Help.
Please read CONTRIBUTING.md before submitting your pull requests.
These are the requirements to create your own local dev environment to contribute to Selenium.
.bazelversion file and transparently passes through all
command-line arguments to the real Bazel binary.JAVA_HOME environment variable to location of Java executable (the JDK not the JRE)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.xcode-select --installbuild --host_platform=//:rosetta to the .bazelrc.local file. We are working
to make sure this isn't required in the long run.Several years ago Jim Evans published a great article on Setting Up a Windows Development Environment for the Selenium .NET Language Bindings; This article is out of date, but it includes more detailed descriptions and screenshots that some people might find useful.
<details> <summary>Click to see Current Windows Setup Requirements</summary>This script will ensure a complete ready to execute developer environment. (nothing is installed or set that is already present unless otherwise prompted)
Set-ExecutionPolicy Bypass -Scope Process -Force to allow running the script in the processSet-ExecutionPolicy -ExecutionPolicy RemoteSigned
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
PATH environment variable (e.g., "C:\tools\msys64\usr\bin")bash.exe location as the BAZEL_SH environment variable (e.g., "C:\tools\msys64\usr\bin\bash.exe")BAZEL_VC environment variable (e.g. "C:\Program Files\Microsoft Visual Studio\2022\Community\VC")BAZEL_VC_FULL_VERSION environment variable (this can be discovered from the directory name in "$BAZEL_VC\Tools\MSVC\<BAZEL_VC_FULL_VERSION>")reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor" /t REG_DWORD /f /v "DisableUNCCheck" /d "1" reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" /t REG_DWORD /f /v "LongPathsEnabled" /d "1"
fsutil 8dot3name set 0C:/tmp instead of nested inside project directory:
selenium/.bazelrc.windows.localIf you want to contribute to the project, but do not want to set up your own local dev environment, there are two alternatives available.
Rather than creating your own local dev environment, GitPod provides a ready to use environment for you.
As an alternative you can build a Dev Container - basically a docker container - suitable for building and testing Selenium using the devcontainer.json in the .devcontainer directory. Supporting IDEs like VS Code or IntelliJ IDEA should point you to how such a container can be created.
You can also build a Docker image suitable for building and testing Selenium using the Dockerfile in the dev image directory.
Selenium is built using a common build tool called Bazel, to allow us to easily manage dependency downloads, generate required binaries, build and release packages, and execute tests; all in a fast, efficient manner. For a more detailed discussion, read Simon Stewart's article on Building Selenium
Often we wrap Bazel commands with our custom Rake wrapper. These are run with the ./go command.
The common Bazel commands are:
bazel build — evaluates dependencies, compiles source files and generates output files for the specified target.
It's used to create executable binaries, libraries, or other artifacts.bazel run — builds the target and then executes it.
It's typically used for targets that produce executable binaries.bazel test — builds and runs the target in a context with additional testing functionalitybazel query — identifies available targets for the provided path.Each module that can be built is defined in a BUILD.bazel file. To execute the module you refer to it starting with a
//, then include the relative path to the file that defines it, then :, then the name of the target.
For example, the target to build the Grid is named executable-grid and it is
defined in the 'selenium/java/src/org/openqa/selenium/grid/BAZEL.build' file.
So to build the grid you would run: bazel build //java/src/org/openqa/selenium/grid:executable-grid.
The Bazel documentation has a handy guide for various shortcuts and all the ways to build multiple targets, which Selenium makes frequent use of.
To build everything for a given language:
bazel build //<language>/...
To build just the grid there is an alias name to use (the log will show where the output jar is located):
bazel build grid
To make things more simple, building each of the bindings is available with this ./go command
./go <language>:build
Most of the team uses Intellij 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.
To use Selenium with the IntelliJ Bazel plugin, import the repository as a Bazel project, and select the project
view file from the scripts directory. ij.bazelproject for Mac/Linux and ij-win.bazelproject for Windows.
We also use Google Java Format for linting, so using the Google Java Formatter Plugin is useful;
there are a few steps to get it working, so read their configuration documentation.
There is also an auto-formatting script that can be run: ./scripts/format.sh
While Selenium is not built with Maven, you can build and install the Selenium pieces
for Maven to use locally by deploying to your local maven repository (~/.m2/repository), using:
./go java:install
Dependencies are defined in the file maven_deps.bzl. To automatically update and pin new dependencies, run:
./go java:update
You can run Python code locally by updating generated files in the python directory using:
./go py:update
To install Selenium locally based on a specific commit, you can use:
./go py:install
Instead of using irb, you can create an interactive REPL with all gems loaded using: bazel run //rb:console
If you want to debug code, you can do it via debug gem:
binding.break to the code where you want the debugger to start.ruby_debug configuration: bazel test --config ruby_debug <test>.bazel-selenium/external/bundle/bin/rdbg -A
If you want to use RubyMine for development, you can configure it use Bazel artifacts:
rb/ as a main project directory.bundle exec rake update as necessary to create up-to-date artifacts. If this does not work, run ./go rb:update from the selenium (parent) directory.../bazel-selenium/external/rules_ruby_dist/dist/bin/ruby.To keep Carbo.Bazel.lock synchronized with Cargo.lock, run:
CARGO_BAZEL_REPIN=true bazel sync --only=crates
There are a number of bazel configurations specific for testing.
Here are examples of arguments we make use of in testing the Selenium code:
--pin_browsers - run specific browser versions defined in the build (versions are updated regularly)--headless - run browsers in headless mode (supported be Chrome, Edge and Firefox)--flaky_test_attempts 3 - re-run failed tests up to 3 times--local_test_jobs 1 - control parallelism of tests--cache_test_results=no, -t- - disable caching of test results and re-runs all of them--test_output all - print all output from the tests, not just errors--test_output streamed - run all tests one by one and print its output immediately--test_env FOO=bar - pass extra environment variable to test process--run_under="xvfb-run -a" - prefix to insert before the executionSelenium tests can be filtered by size:
These can be filtered using the test_size_filters argument like this:
bazel test //<language>/... --test_size_filters=small
Tests can also be filtered by tag like:
bazel test //<language>/... --test_tag_filters=this,-not-this
To run unit tests:
bazel test //java/... --test_size_filters=small
To run integration tests:
bazel test //java/... --test_size_filters=medium
To run browser tests:
bazel test //java/... --test_size_filters=large --test_tag_filters=<browser>
To run a specific test:
</details>bazel test //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest
To run the tests run:
bazel test //javascript/node/selenium-webdriver:tests
You can use --test_env to pass in the browser name as SELENIUM_BROWSER.
</details>bazel test //javascript/node/selenium-webdriver:tests --test_env=SELENIUM_BROWSER=firefox
Run unit tests with:
bazel test //py:unit
To run tests with a specific browser:
bazel test //py:test-<browsername>
To run all Python tests:
</details>bazel test //py:all
Test targets:
| Command | Description |
|---|---|
bazel test //rb/... | Run unit, all integration tests and lint |
bazel test //rb:lint | Run RuboCop linter |
bazel test //rb/spec/... | Run unit and integration tests for all browsers |
bazel test //rb/spec/... --test_size_filters small | Run unit tests |
bazel test //rb/spec/unit/... | Run unit tests |
bazel test //rb/spec/... --test_size_filters large | Run integration tests for all browsers |
bazel test //rb/spec/integration/... | Run integration tests for all browsers |
bazel test //rb/spec/integration/... --test_tag_filters firefox | Run integration tests for local Firefox only |
bazel test //rb/spec/integration/... --test_tag_filters firefox-remote | Run integration tests for remote Firefox only |
bazel test //rb/spec/integration/... --test_tag_filters firefox,firefox-remote | Run integration tests for local and remote Firefox |
Ruby test targets have the same name as the spec file with _spec.rb removed, so you can run them individually.
Integration tests targets also have a browser and remote suffix to control which browser to pick and whether to use Grid.
| Test file | Test target |
|---|---|
rb/spec/unit/selenium/webdriver/proxy_spec.rb | //rb/spec/unit/selenium/webdriver:proxy |
rb/spec/integration/selenium/webdriver/driver_spec.rb | //rb/spec/integration/selenium/webdriver:driver-chrome |
rb/spec/integration/selenium/webdriver/driver_spec.rb | //rb/spec/integration/selenium/webdriver:driver-chrome-remote |
rb/spec/integration/selenium/webdriver/driver_spec.rb | //rb/spec/integration/selenium/webdriver:driver-firefox |
rb/spec/integration/selenium/webdriver/driver_spec.rb | //rb/spec/integration/selenium/webdriver:driver-firefox-remote |
Supported browsers:
chromeedgefirefoxfirefox-betaiesafarisafari-previewIn addition to the Common Options Examples, here are some additional Ruby specific ones:
--test_arg "-eTimeouts" - test only specs which name include "Timeouts"--test_arg "<any other RSpec argument>" - pass any extra RSpec arguments (see `bazel run @bundle//bin:rspec --

AI赋能电商视觉革命,一站式智能商拍平台
潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。


企业专属的AI法律顾问
iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。


稳定高效的流量提升解决方案,助力品牌曝光
稳定高效的流量提升解决方案,助力品牌曝光


最新版Sora2模型免费使用,一键生成无水印视频
最新版Sora2模型免费使用,一键生成无水印视频


实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。


选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。


AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。


最强AI数据分析助手
小浣熊家族Raccoon,您的AI智能助手,致力于通过先进的人工智能技术,为用户提供高效、便捷的智能服务。无论是日常咨询还是专业问题解答,小浣熊都能以快速、准确的响应满足您的需求,让您的生活更加智能便捷。


像人一样思考的AI智能体
imini 是一款超级AI智能体,能根据人类指令,自主思考、自主完成、并且交付结果的AI智能体。


AI数字人视频创作平台
Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。
最新AI工具、AI资讯
独家AI资源 、AI项目落地

微信扫一扫关注公众号