Updating .NET tests
4 files changed
tree: d91d7a6a5c18725bbc28e7817acbd433a4e333cc
  1. .github/
  2. .idea/
  3. common/
  4. cpp/
  5. deploys/
  6. dotnet/
  7. java/
  8. javascript/
  9. py/
  10. rake_tasks/
  11. rb/
  12. scripts/
  13. third_party/
  14. .bazelignore
  15. .bazelrc
  16. .bazelversion
  17. .editorconfig
  18. .git-fixfiles
  19. .gitattributes
  20. .gitignore
  21. .mailmap
  22. .OLD_AUTHORS
  23. .travis.yml
  24. appveyor.yml
  25. AUTHORS
  26. BUILD.bazel
  27. CONTRIBUTING.md
  28. copy_file.bzl
  29. copyiedriver.bat
  30. generate_api_docs.sh
  31. go
  32. go.bat
  33. LICENSE
  34. NOTICE
  35. package-lock.json
  36. package.json
  37. Rakefile
  38. README.md
  39. selenium.iml
  40. sonar-project.properties
  41. WORKSPACE
README.md

Selenium Travis Status AppVeyor Status

Selenium is an umbrella project encapsulating a variety of tools and libraries enabling web browser automation. Selenium specifically provides 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.

Documentation

Narrative documentation:

API documentation:

Pull Requests

Please read CONTRIBUTING.md before submitting your pull requests.

Building

In order to build Selenium, you'll generally use the ./go command. ./go is a Rake script, which wraps the main build too, bazel.

Bazel

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.

Before Building

Ensure that you have Chrome installed and the chromedriver that matches your Chrome version available on your $PATH. You may have to update this from time to time.

Common Build Targets

To build the most commonly-used modules of Selenium from source, execute this command from the root project folder:

bazel build java/...

If you have some extra time on your hands, you can run this command to get extra confidence that your build is successful. This will do a lot more work to build all the javascript artifacts:

bazel build java/... javascript/...

If you're making changes to the java/ or javascript/ folders in this project, and this command executes without errors, you should be able to create a PR of your changes. (See also CONTRIBUTING.md)

Build Details

  • 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
  • There is also a main Rakefile

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:

./go javascript/atoms:test:run

In this case, javascript/atoms is the module directory, test is a target in that directory's build.desc file, and run is the action to run on that target.

As you see build targets scroll past in the log, you may want to run them individually. crazyfun can run them individually, by target name, as long as :run is appended (see above).

To list all available targets, you can append the -T flag:

./go -T

Requirements

  • The latest version of the Java 11 OpenJDK
  • java and jar on the PATH (make sure you use java 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.
  • Python
  • python on the PATH
  • The Requests Library for Python: pip install requests
  • MacOS users should have the latest version of Xcode installed, including the command-line tools. The following command should work:
xcode-select --install

Although the build system is based on rake, it‘s strongly advised to rely on the version of JRuby in third_party/ that is invoked by go. The only developer type who would want to deviate from this is the “build maintainer” who’s experimenting with a JRuby upgrade.

Optional Requirements

  • Python 3.5+ (if you want to run Python tests for this version)
  • Ruby 2.0

Internet Explorer Driver

If you plan to compile the IE driver, you also need:

The build will work on any platform, but the tests for IE will be skipped silently if you are not building on Windows.

Common Tasks (Bazel)

To build the bulk of the Selenium binaries from source, run the following command from the root folder:

bazel build java/... javascript/...

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 with the --test_size_filters option:

bazel test --test_size_filters=small,medium java/...

Bazel's “test” command will run all tests in the package, including integration tests. Expect the test java/... to launch browsers and consume a considerable amount of time and resources.

Tour

The code base is generally segmented around the languages used to write the component. Selenium makes extensive use of JavaScript, so let's start there. Working on the JavaScript is easy. First of all, start the development server:

./go debug-server

Now, navigate to http://localhost:2310/javascript. You'll find the contents of the javascript/ directory being shown. We use the Closure Library for developing much of the JavaScript, so now navigate to http://localhost:2310/javascript/atoms/test.

The tests in this directory are normal HTML files with names ending with _test.html. Click on one to load the page and run the test. You can run all the JavaScript tests using:

./go test_javascript

Maven POM files

Here is the public Selenium Maven repository.

Build Output

./go only makes a top-level build directory. Outputs are placed under that relative to the target name. Which is probably best described with an example. For the target:

./go //java/client/src/org/openqa/selenium:selenium-api

The output is found under:

build/java/client/src/org/openqa/selenium/selenium-api.jar

If you watch the build, each step should print where its output is going. Java test outputs appear in one of two places: either under build/test_logs for JUnit or in build/build_log.xml for TestNG tests. If you'd like the build to be chattier, just append log=true to the build command line.

Help with go

More general, but basic, help for go

./go --help

go is just a wrapper around Rake, so you can use the standard commands such as rake -T to get more information about available targets.

Maven per se

If it is not clear already, Selenium is not built with Maven. It is built with bazel, though that is invoked with go as outlined above, so you do not really 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 (~/.m2/repository), while skipping Selenium's own tests.

./go maven-install

The maven jars should now be in your local ~/.m2/repository.

Useful Resources

Refer to the Building Web Driver wiki page for the last word on building the bits and pieces of Selenium.

Bazel Installation/Troubleshooting

MacOS

bazelisk

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

Xcode

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:

xcode-select -p

If the value is /Applications/Xcode.app/Contents/Developer/, you can proceed with bazelisk installation. If, however, the return value is /Library/Developer/CommandLineTools/, you'll 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)