Skip to content

Instantly share code, notes, and snippets.

@krmahadevan
Last active October 14, 2022 05:07
Show Gist options
  • Save krmahadevan/6d79cf890e0c120becf2969e7791862a to your computer and use it in GitHub Desktop.
Save krmahadevan/6d79cf890e0c120becf2969e7791862a to your computer and use it in GitHub Desktop.
Bazel games in Selenium (Java focussed )

Bazel games in Selenium (Java focussed )

Some mandatory reading materials

Commands to remember

List all targets in Selenium Bazel project

To list all targets run the below command in the directory that contains the WORKSPACE file (Remember this is the root directory of the bazel project)

bazel query //...

The above output can be quite verbose, so remember to redirect the output to some text file using a command that looks like below:

bazel query //... > ~/Desktop/targets.txt

Here we are redirecting the output to ~/Desktop/targets.txt

I want to build the Grid locally

Run the below command for building the grid

bazel build grid

This command is going to compile the relevant java classes, run tests and then build a jar file out of it.

You will find the built artifact (jar in this case) at the below location:

bazel-bin/java/src/org/openqa/selenium/grid/ in the root directory (The one that contains WORKSPACE file) and it would be called grid-project.jar

Running the Java based tests

Refer:

Small tests

bazel test --cache_test_results=no --test_size_filters=small grid java/test/...

Large tests

bazel test --cache_test_results=no java/test/org/openqa/selenium/grid/router:large-tests

Browser tests

bazel test --test_size_filters=small,medium --cache_test_results=no --test_tag_filters=-browser-test //java/...

Consuming locally built selenium Grid jar

Here am going to conveniently assume that you are working with Maven project.

  1. Update the version to whatever you want in the file selenium/java/version.bzl (for e.g., 9.8.7)
  2. Now from the root directory ( the directory that contains the file WORKSPACE) run the command : ./go maven-install
  3. Now in your test project you can set the version to the version you just now published (for e.g., in this case it would be 9.8.7) as the maven dependency and you are good to go!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment