A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/SeleniumHQ/selenium.git below:

SeleniumHQ/selenium: A browser automation framework and ecosystem.



Selenium
Automates browsers. That's it!

ContributingInstallingBuildingDevelopingTestingDocumentingReleasing

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.

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.

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.

Click to see Current Windows Setup Requirements Option 1: Automatic Installation from Scratch

This script will ensure a complete ready to execute developer environment. (nothing is installed or set that is already present unless otherwise prompted)

  1. Open Powershell as an Administrator
  2. Execute: Set-ExecutionPolicy Bypass -Scope Process -Force to allow running the script in the process
  3. Navigate to the directory you want to clone Selenium in, or the parent directory of an already cloned Selenium repo
  4. Download and execute this script in the powershell terminal: [scripts/dev-environment-setup.ps1]`
Option 2: Manual Installation
  1. Allow running scripts in Selenium in general:
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
    
  2. Enable Developer Mode:
    reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
    
  3. Install MSYS2, which is an alternative shell environment that provides Unix-like commands
  4. Install the latest version of Visual Studio Community
  5. Add support for long file names (bazel has a lot of nested directories that can exceed default limits in Windows)
    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"
Alternative Dev Environments

If 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:

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):

To make things more simple, building each of the bindings is available with this ./go command

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:

Dependencies are defined in the file MODULE.bazel.

To update a dependency, modify the version in the MODULE.bazel file and run:

RULES_JVM_EXTERNAL_REPIN=1 bazel run @maven//:pin

To automatically update and pin new dependencies, run:

We follow the PEP8 Style Guide for Python Code (except we use a 120 character line length). This is checked and enforced with ruff, a linting/formatting tool. There is also an auto-formatting script that can be run: ./scripts/format.sh

To run Python code locally without building/installing the package, you must first install the dependencies:

pip install -r py/requirements.txt

Then, build the generated files and copy them into your local source tree:

After that, you can import the selenium package directly from source from the py directory.

Instead of running from source, you can build and install the selenium package (wheel) locally:

This will attempt to install into the global Python site-packages directory, which might not be writable. To avoid this, you should create and activate a virtual environment before installing.

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:

  1. Add binding.break to the code where you want the debugger to start.
  2. Run tests with ruby_debug configuration: bazel test --config ruby_debug <test>.
  3. When debugger starts, run the following in a separate terminal to connect to debugger:
bazel-selenium/external/bundle/bin/rdbg -A

If you want to use RubyMine for development, you can configure it use Bazel artifacts:

  1. Open rb/ as a main project directory.
  2. Run 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.
  3. In Settings / Languages & Frameworks / Ruby SDK and Gems add new Interpreter pointing to ../bazel-selenium/external/rules_ruby_dist/dist/bin/ruby.
  4. You should now be able to run and debug any spec. It uses Chrome by default, but you can alter it using environment variables specified in Ruby Testing section below.

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:

Selenium 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

If there are multiple --test_tag_filters, only the last one is considered, so be careful if also using an inherited config

Click to see Java Test Commands

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:

bazel test //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest
Click to see JavaScript Test Commands

To run the tests run:

bazel test //javascript/selenium-webdriver:all

You can use --test_env to pass in the browser name as SELENIUM_BROWSER.

bazel test //javascript/selenium-webdriver:all --test_env=SELENIUM_BROWSER=firefox
Click to see Python Test Commands

Run unit tests with:

To run common tests with a specific browser:

bazel test //py:common-<browsername>

To run common tests with a specific browser (include BiDi tests):

bazel test //py:common-<browsername>-bidi

To run tests with a specific browser:

bazel test //py:test-<browsername>

To run all Python tests:

Click to see Ruby Test Commands

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:

In addition to the Common Options Examples, here are some additional Ruby specific ones:

Supported environment variables for use with --test_env:

To run with a specific version of Ruby you can change the version in rb/.ruby-version or from command line:

echo '<X.Y.Z>' > rb/.ruby-version
Click to see .NET Test Commands

.NET tests currently only work with pinned browsers, so make sure to include that.

Run all tests with:

bazel test //dotnet/test/common:AllTests --pin_browsers=true

You can run specific tests by specifying the class name:

bazel test //dotnet/test/common:ElementFindingTest --pin_browsers=true

If the module supports multiple browsers:

bazel test //dotnet/test/common:ElementFindingTest-edge --pin_browsers=true
Click to see Rust Test Commands

Rust tests are run with:

Click to see Linux Testing Requirements

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.

  1. Run the X server Xvfb :99 or Xnest :99
  2. Run a window manager, for example, DISPLAY=:99 jwm
  3. 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 --run_under functionality:

bazel test --run_under="xvfb-run -a" //java/...

API documentation can be found here:

To update API documentation for a specific language: ./go <language>:docs

To update all documentation: ./go all:docs

Note that JavaScript generation is currently broken.

The full process for doing a release can be found in the wiki

Releasing is a combination of building and publishing, which often requires coordination of multiple executions and additional processing. As discussed in the Building section, we use Rake tasks with the ./go command for these things. These ./go commands include the --stamp argument to provide necessary information about the constructed asset.

You can build and release everything with:

To build and release a specific language:

If you have access to the Selenium EngFlow repository, you can have the assets built remotely and downloaded locally using:

./go all:release['--config', 'release']

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4