diff --git a/rb/BUILD.bazel b/rb/BUILD.bazel index 7b0dc2df53de8..71405d5db74be 100644 --- a/rb/BUILD.bazel +++ b/rb/BUILD.bazel @@ -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", diff --git a/rb/lib/selenium/webdriver/BUILD.bazel b/rb/lib/selenium/webdriver/BUILD.bazel index ff5d94e2330ea..44b1e16651595 100644 --- a/rb/lib/selenium/webdriver/BUILD.bazel +++ b/rb/lib/selenium/webdriver/BUILD.bazel @@ -20,6 +20,13 @@ rb_library( srcs = glob([ "bidi/**/*.rb", "bidi.rb", + ]), + deps = [":common"], +) + +rb_library( + name = "devtools", + srcs = glob([ "devtools/**/*.rb", "devtools.rb", ]), diff --git a/rb/spec/integration/selenium/webdriver/BUILD.bazel b/rb/spec/integration/selenium/webdriver/BUILD.bazel index f786bb224308f..6e45b3c10a282 100644 --- a/rb/spec/integration/selenium/webdriver/BUILD.bazel +++ b/rb/spec/integration/selenium/webdriver/BUILD.bazel @@ -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], @@ -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 ] [ @@ -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", + ], + ) + for f in _DEVTOOLS +] diff --git a/rb/spec/integration/selenium/webdriver/bidi/BUILD.bazel b/rb/spec/integration/selenium/webdriver/bidi/BUILD.bazel index 7cb22df532822..5b3b700e354bc 100644 --- a/rb/spec/integration/selenium/webdriver/bidi/BUILD.bazel +++ b/rb/spec/integration/selenium/webdriver/bidi/BUILD.bazel @@ -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", ], ) diff --git a/rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel b/rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel index 6a151a939201d..9f2694a3d89b8 100644 --- a/rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel +++ b/rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel @@ -23,8 +23,9 @@ rb_integration_test( "chrome", "chrome-beta", ], + no_grid = True, tags = [ - "no-grid", + "se-manager", "skip-rbe", ], ) diff --git a/rb/spec/integration/selenium/webdriver/edge/BUILD.bazel b/rb/spec/integration/selenium/webdriver/edge/BUILD.bazel index 5b53d544625f0..a316584e05463 100644 --- a/rb/spec/integration/selenium/webdriver/edge/BUILD.bazel +++ b/rb/spec/integration/selenium/webdriver/edge/BUILD.bazel @@ -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", ], ) diff --git a/rb/spec/integration/selenium/webdriver/firefox/BUILD.bazel b/rb/spec/integration/selenium/webdriver/firefox/BUILD.bazel index b91f2c6d088af..8098a42be3116 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/BUILD.bazel +++ b/rb/spec/integration/selenium/webdriver/firefox/BUILD.bazel @@ -23,8 +23,9 @@ rb_integration_test( "firefox", "firefox-beta", ], + no_grid = True, tags = [ - "no-grid", + "se-manager", "skip-rbe", ], ) diff --git a/rb/spec/tests.bzl b/rb/spec/tests.bzl index 48cf807ba7f23..4982c605209dd 100644 --- a/rb/spec/tests.bzl +++ b/rb/spec/tests.bzl @@ -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", @@ -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", @@ -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", @@ -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, @@ -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", @@ -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"] + @@ -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__"], ) diff --git a/rb/spec/unit/selenium/webdriver/devtools/BUILD.bazel b/rb/spec/unit/selenium/webdriver/devtools/BUILD.bazel index 7b01c0fc5d000..ddc1bb62cd6b1 100644 --- a/rb/spec/unit/selenium/webdriver/devtools/BUILD.bazel +++ b/rb/spec/unit/selenium/webdriver/devtools/BUILD.bazel @@ -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"]) ]