Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ 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 |
Expand All @@ -406,23 +406,29 @@ Test targets:
| `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 bidi` | Run integration tests for all bidi tests |
| `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` |
Integration tests targets also allow specific suffixes to control specific browsers and settings.
These targets are dynamically generated in the `rb/spec/tests.bzl` file
Running in BiDi mode will be increasingly important as we re-implement classic selenium functionality with BiDi protocol.
Not every test is set to run with BiDi by default, and which spec files are valid is explicitly
with the `BIDI_BROWSERS` in the `tests.bzl` file and `_BIDI_FILES` in `//rb/spec/integration/selenium/webdriver/BUILD.bazel`

| 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-firefox-beta` |
| `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-bidi` |
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-chrome-remote-bidi` |

Supported browsers:

* `chrome`
* `chrome-beta`
* `edge`
* `firefox`
* `firefox-beta`
Expand All @@ -441,6 +447,7 @@ Supported environment variables for use with `--test_env`:
- `WD_REMOTE_URL` - URL of an already running server to use for remote tests
- `DOWNLOAD_SERVER` - when `WD_REMOTE_URL` not set; whether to download and use most recently released server version for remote tests
- `DEBUG` - turns on verbose debugging
- `WEBDRIVER_BIDI` - enables `web_socket_url` in the capabilities
- `HEADLESS` - for chrome, edge and firefox; runs tests in headless mode
- `DISABLE_BUILD_CHECK` - for chrome and edge; whether to ignore driver and browser version mismatches (allows testing Canary builds)
- `CHROME_BINARY` - path to test specific Chrome browser
Expand Down
3 changes: 2 additions & 1 deletion rb/spec/integration/selenium/webdriver/bidi/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
load("//rb/spec:tests.bzl", "rb_integration_test")
load("//rb/spec:tests.bzl", "BIDI_BROWSERS", "rb_integration_test")

[
rb_integration_test(
name = file[:-8],
srcs = [file],
browsers = BIDI_BROWSERS,
tags = [
"bidi",
"exclusive-if-local",
Expand Down
36 changes: 35 additions & 1 deletion rb/spec/tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ load(
"firefox_data",
)

BIDI_BROWSERS = [
"chrome",
"chrome-beta",
"edge",
"firefox",
"firefox-beta",
]

BROWSERS = {
"chrome": {
"data": chrome_data,
Expand Down Expand Up @@ -215,7 +223,7 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
)

# Generate a test target for bidi browser execution if there is a matching tag
if "bidi" in tags:
if "bidi" in tags and browser in BIDI_BROWSERS:
rb_test(
name = "{}-{}-bidi".format(name, browser),
size = "large",
Expand All @@ -233,6 +241,32 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
visibility = ["//rb:__subpackages__"],
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
)
rb_test(
name = "{}-{}-remote-bidi".format(name, browser),
size = "large",
srcs = srcs,
args = ["rb/spec/"],
data = BROWSERS[browser]["data"] + data + [
"//common/src/web",
"//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar",
"//rb/spec:java-location",
"@bazel_tools//tools/jdk:current_java_runtime",
],
env = BROWSERS[browser]["env"] | {
"WD_BAZEL_JAVA_LOCATION": "$(rootpath //rb/spec:java-location)",
"WD_SPEC_DRIVER": "remote",
"WEBDRIVER_BIDI": "true",
},
main = "@bundle//bin:rspec",
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + ["{}-remote-bidi".format(browser)],
deps = depset(
["//rb/spec/integration/selenium/webdriver:spec_helper", "//rb/lib/selenium/webdriver:bidi"] +
BROWSERS[browser]["deps"] +
deps,
),
visibility = ["//rb:__subpackages__"],
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
)

def rb_unit_test(name, srcs, deps, data = []):
rb_test(
Expand Down
Loading