Skip to content
Merged
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
1 change: 1 addition & 0 deletions rb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ rb_gem_build(
"//rb/lib/selenium/webdriver:bidi",
"//rb/lib/selenium/webdriver:chrome",
"//rb/lib/selenium/webdriver:common",
"//rb/lib/selenium/webdriver:devtools",
"//rb/lib/selenium/webdriver:edge",
"//rb/lib/selenium/webdriver:firefox",
"//rb/lib/selenium/webdriver:ie",
Expand Down
7 changes: 7 additions & 0 deletions rb/lib/selenium/webdriver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ rb_library(
srcs = glob([
"bidi/**/*.rb",
"bidi.rb",
]),
deps = [":common"],
)

rb_library(
name = "devtools",
srcs = glob([
"devtools/**/*.rb",
"devtools.rb",
]),
Expand Down
86 changes: 54 additions & 32 deletions rb/spec/integration/selenium/webdriver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ rb_library(
],
)

_OS_SENSITIVE = [
"action_builder_spec.rb",
"takes_screenshot_spec.rb",
"window_spec.rb",
]

# specs whose classes have both bidi implementations
_BIDI_IMPLEMENTATIONS = [
"navigation_spec.rb",
]

# tests that require bidi enabled
_BIDI_ONLY = [
"bidi_spec.rb",
"network_spec.rb",
]

_DEVTOOLS = ["devtools_spec.rb"]

[
rb_integration_test(
name = file[:-8],
Expand All @@ -37,21 +56,20 @@ rb_library(
)
for file in glob(
["*_spec.rb"],
exclude = [
"bidi_spec.rb",
"driver_spec.rb",
"devtools_spec.rb",
"element_spec.rb",
"navigation_spec.rb",
"network_spec.rb",
],
exclude = _OS_SENSITIVE + _BIDI_IMPLEMENTATIONS + _BIDI_ONLY + _DEVTOOLS,
)
]

_BIDI_FILES = [
"bidi_spec.rb",
"navigation_spec.rb",
"network_spec.rb",
[
rb_integration_test(
name = f[:-8],
srcs = [f],
tags = ["os-sensitive"],
deps = [
"//rb/lib/selenium/webdriver:common",
],
)
for f in _OS_SENSITIVE
]

[
Expand All @@ -60,29 +78,33 @@ _BIDI_FILES = [
srcs = [f],
tags = ["bidi"],
deps = [
"//rb/lib/selenium/devtools",
"//rb/lib/selenium/webdriver:bidi",
],
)
for f in _BIDI_FILES
for f in _BIDI_IMPLEMENTATIONS
]

rb_integration_test(
name = "devtools",
srcs = ["devtools_spec.rb"],
tags = ["exclusive-if-local"],
deps = [
"//rb/lib/selenium/devtools",
"//rb/lib/selenium/webdriver:bidi",
],
)

rb_integration_test(
name = "driver",
srcs = ["driver_spec.rb"],
)
[
rb_integration_test(
name = f[:-8],
srcs = [f],
bidi_only = True,
deps = [
"//rb/lib/selenium/webdriver:bidi",
],
)
for f in _BIDI_ONLY
]

rb_integration_test(
name = "element",
srcs = ["element_spec.rb"],
)
[
rb_integration_test(
name = f[:-8],
srcs = [f],
tags = ["exclusive-if-local"],
deps = [
"//rb/lib/selenium/devtools",
"//rb/lib/selenium/webdriver:devtools",
],
)
Comment thread
titusfortner marked this conversation as resolved.
for f in _DEVTOOLS
]
7 changes: 2 additions & 5 deletions rb/spec/integration/selenium/webdriver/bidi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ load("//rb/spec:tests.bzl", "rb_integration_test")
rb_integration_test(
name = file[:-8],
srcs = [file],
tags = [
"bidi",
"exclusive-if-local",
],
bidi_only = True,
tags = ["exclusive-if-local"],
deps = [
"//rb/lib/selenium/devtools",
"//rb/lib/selenium/webdriver:bidi",
],
)
Expand Down
3 changes: 2 additions & 1 deletion rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ rb_integration_test(
"chrome",
"chrome-beta",
],
no_grid = True,
tags = [
"no-grid",
"se-manager",
"skip-rbe",
],
)
3 changes: 2 additions & 1 deletion rb/spec/integration/selenium/webdriver/edge/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ rb_integration_test(
name = "service",
srcs = ["service_spec.rb"],
browsers = ["edge"],
no_grid = True,
tags = [
"no-grid",
"se-manager",
"skip-rbe",
],
)
3 changes: 2 additions & 1 deletion rb/spec/integration/selenium/webdriver/firefox/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ rb_integration_test(
"firefox",
"firefox-beta",
],
no_grid = True,
tags = [
"no-grid",
"se-manager",
"skip-rbe",
],
)
106 changes: 65 additions & 41 deletions rb/spec/tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ BROWSERS = {
"deps": ["//rb/lib/selenium/webdriver:chrome"],
"tags": [],
"target_compatible_with": [],
"bidi": True,
"env": {
"WD_REMOTE_BROWSER": "chrome",
"WD_SPEC_DRIVER": "chrome",
Expand All @@ -62,6 +63,7 @@ BROWSERS = {
"deps": ["//rb/lib/selenium/webdriver:edge"],
"tags": [],
"target_compatible_with": [],
"bidi": True,
"env": {
"WD_REMOTE_BROWSER": "edge",
"WD_SPEC_DRIVER": "edge",
Expand Down Expand Up @@ -108,6 +110,7 @@ BROWSERS = {
"deps": ["//rb/lib/selenium/webdriver:firefox"],
"tags": [],
"target_compatible_with": [],
"bidi": True,
"env": {
"WD_REMOTE_BROWSER": "firefox",
"WD_SPEC_DRIVER": "firefox",
Expand Down Expand Up @@ -165,7 +168,25 @@ BROWSERS = {

DEFAULT_BROWSERS = [b for b in BROWSERS.keys() if b not in ("ie", "safari-preview")]

def rb_integration_test(name, srcs, deps = [], data = [], browsers = DEFAULT_BROWSERS, tags = []):
# Tags listed here apply only to the local target of the listed browsers.
_BROWSER_TAG_FILTERS = {
"os-sensitive": ["chrome-beta", "edge", "firefox-beta", "safari"],
}

def _split_filtered_tags(tags, browser):
universal_tags = [t for t in tags if t not in _BROWSER_TAG_FILTERS]
local_tags = [t for t in tags if browser in _BROWSER_TAG_FILTERS.get(t, [])]
return universal_tags, local_tags

def rb_integration_test(
name,
srcs,
deps = [],
data = [],
browsers = DEFAULT_BROWSERS,
tags = [],
bidi_only = False,
no_grid = False):
# Generate a library target that is used by //rb/spec:spec to expose all tests to //rb:lint.
rb_library(
name = name,
Expand All @@ -174,46 +195,49 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = DEFAULT_BRO
)

for browser in browsers:
# Generate a test target for local browser execution.
rb_test(
name = "{}-{}".format(name, browser),
size = "large",
srcs = srcs,
args = ["rb/spec/"],
data = BROWSERS[browser]["data"] + data + ["//common/src/web"],
env = BROWSERS[browser]["env"],
main = "@bundle//bin:rspec",
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + [browser],
deps = ["//rb/spec/integration/selenium/webdriver:spec_helper"] + BROWSERS[browser]["deps"] + deps,
visibility = ["//rb:__subpackages__"],
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
)
universal_tags, local_tags = _split_filtered_tags(tags, browser)
if not bidi_only:
# Generate a test target for local browser execution.
rb_test(
name = "{}-{}".format(name, browser),
size = "large",
srcs = srcs,
args = ["rb/spec/"],
data = BROWSERS[browser]["data"] + data + ["//common/src/web"],
env = BROWSERS[browser]["env"],
main = "@bundle//bin:rspec",
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + universal_tags + local_tags + [browser],
deps = ["//rb/spec/integration/selenium/webdriver:spec_helper"] + BROWSERS[browser]["deps"] + deps,
visibility = ["//rb:__subpackages__"],
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
)

# Generate a test target for remote browser execution (Grid).
rb_test(
name = "{}-{}-remote".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",
},
main = "@bundle//bin:rspec",
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + ["{}-remote".format(browser)],
deps = ["//rb/spec/integration/selenium/webdriver:spec_helper"] + BROWSERS[browser]["deps"] + deps,
visibility = ["//rb:__subpackages__"],
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
)
# Generate a test target for remote browser execution (Grid).
if not no_grid:
rb_test(
name = "{}-{}-remote".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",
},
main = "@bundle//bin:rspec",
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + universal_tags + ["{}-remote".format(browser)],
deps = ["//rb/spec/integration/selenium/webdriver:spec_helper"] + BROWSERS[browser]["deps"] + deps,
visibility = ["//rb:__subpackages__"],
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
)

# Generate a test target for bidi browser execution if there is a matching tag
if "bidi" in tags:
# Generate a test target for bidi browser execution on browsers that opt in.
if ("bidi" in tags or bidi_only) and BROWSERS[browser].get("bidi", False):
rb_test(
name = "{}-{}-bidi".format(name, browser),
size = "large",
Comment thread
titusfortner marked this conversation as resolved.
Comment thread
titusfortner marked this conversation as resolved.
Expand All @@ -222,7 +246,7 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = DEFAULT_BRO
data = BROWSERS[browser]["data"] + data + ["//common/src/web"],
env = BROWSERS[browser]["env"] | {"WEBDRIVER_BIDI": "true"},
main = "@bundle//bin:rspec",
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + ["{}-bidi".format(browser)],
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + universal_tags + ["{}-bidi".format(browser)],
deps = {d: True for d in (
["//rb/spec/integration/selenium/webdriver:spec_helper", "//rb/lib/selenium/webdriver:bidi"] +
BROWSERS[browser]["deps"] +
Expand All @@ -241,7 +265,7 @@ def rb_unit_test(name, srcs, deps, data = [], flaky = False):
flaky = flaky,
main = "@bundle//bin:rspec",
data = data,
tags = ["no-sandbox"], # TODO: Do we need this?
tags = ["unit"],
deps = ["//rb/spec/unit/selenium/webdriver:spec_helper"] + deps,
visibility = ["//rb:__subpackages__"],
)
2 changes: 1 addition & 1 deletion rb/spec/unit/selenium/webdriver/devtools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("//rb/spec:tests.bzl", "rb_unit_test")
rb_unit_test(
name = file[:-8],
srcs = [file],
deps = ["//rb/lib/selenium/webdriver:bidi"],
deps = ["//rb/lib/selenium/webdriver:devtools"],
)
for file in glob(["*_spec.rb"])
]
Loading