diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 0d2235f2..69e5bb7b 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,26 +1,28 @@ --- -platforms: - ubuntu2204: - build_targets: - - "//..." +tasks: + web_testing_python_ubuntu2004: + name: "rules_web_testing_python in ubuntu" + platform: ubuntu2004 + shell_commands: + - "sudo apt -y update && sudo apt -y install libxcb1" test_flags: - - "--test_tag_filters=-noci,-external,-native,-sauce" - test_targets: - - "//..." - macos: - build_targets: - - "//..." + - "--test_tag_filters=-noci,-sauce" + build_targets: [ "..." ] + test_targets: [ "..." ] + working_directory: web_testing_python + web_testing_python_macos: + name: "rules_web_testing_python in macos" + platform: macos test_flags: - - "--test_tag_filters=-noci,-sauce,-external,-native" - test_targets: - - "//..." - windows: - build_flags: - - "--enable_runfiles" - build_targets: - - "//..." + - "--test_tag_filters=-noci,-sauce" + build_targets: [ "..." ] + test_targets: [ "..." ] + working_directory: web_testing_python + web_testing_python_windows: + name: "rules_web_testing_python in windows" + platform: windows test_flags: - - "--test_tag_filters=-noci,-sauce,-external,-native" - - "--enable_runfiles" - test_targets: - - "//..." + - "--test_tag_filters=-noci,-sauce" + build_targets: [ "..." ] + test_targets: [ "..." ] + working_directory: web_testing_python \ No newline at end of file diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 00000000..9dad43df --- /dev/null +++ b/.bazelignore @@ -0,0 +1,4 @@ +web_testing_go +web_testing_java +web_testing_python +web_testing_scala diff --git a/BUILD.bazel b/BUILD.bazel index af1d9d52..ab52bbb1 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -15,7 +15,6 @@ ################################################################################ # load("@bazel_gazelle//:def.bzl", "gazelle") -load("@python_versions//3.11:defs.bzl", "compile_pip_requirements") licenses(["notice"]) # Apache 2.0 @@ -25,11 +24,3 @@ gazelle( name = "gazelle", prefix = "github.com/bazelbuild/rules_webtesting", ) - -compile_pip_requirements( - name = "requirements", - requirements_in = "requirements.in", - requirements_txt = "requirements_lock.txt", - requirements_windows = "requirements_lock_windows.txt", -) - diff --git a/MODULE.bazel b/MODULE.bazel index 17754659..ac865778 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -4,80 +4,26 @@ module( ) bazel_dep(name = "bazel_skylib", version = "1.7.1") + bazel_dep(name = "platforms", version = "0.0.10") ##### Go dependencies ##### bazel_dep(name = "rules_go", version = "0.51.0-rc1", repo_name = "io_bazel_rules_go") + bazel_dep(name = "gazelle", version = "0.40.0", repo_name = "bazel_gazelle") go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps") + go_deps.from_file(go_mod = "//:go.mod") # All *direct* Go dependencies of the module have to be listed explicitly. -use_repo( - go_deps, - "com_github_gorilla_mux", - "com_github_tebeka_selenium", -) - -##### Java dependencies ##### -bazel_dep(name = "rules_jvm_external", version = "6.6") - -maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") -maven.install( - artifacts = [ - "com.google.guava:guava:33.2.1-jre", - "org.seleniumhq.selenium:selenium-remote-driver:4.27.0", - "org.seleniumhq.selenium:selenium-api:4.27.0", - "junit:junit:4.13.2", - ], -) -use_repo(maven, "maven") - -##### Python dependencies ##### -bazel_dep(name = "rules_python", version = "1.0.0") - -python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain( - is_default = True, - python_version = "3.11", -) -use_repo(python, "python_3_11", "python_versions") - -pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") -pip.parse( - hub_name = "rules_webtesting_py_deps", - python_version = "3.11", - requirements_lock = "//:requirements_lock.txt", - requirements_windows = "requirements_lock_windows.txt", -) -use_repo(pip, "rules_webtesting_py_deps") - -##### Scala dependencies ##### -bazel_dep(name = "rules_scala", repo_name = "io_bazel_rules_scala") - -# TODO: Switch to a release version once it's available in BCR. -# Otherwise, the root module has to declare the same override. -git_override( - module_name = "rules_scala", - commit = "219e63983e8e483e66ebf70372969ba227382001", - remote = "https://github.com/mbland/rules_scala", -) - -scala_deps = use_extension( - "@io_bazel_rules_scala//scala/extensions:deps.bzl", - "scala_deps", -) -scala_deps.settings( - fetch_sources = True, -) -scala_deps.toolchains( - scalatest = True, -) +use_repo(go_deps, "com_github_gorilla_mux", "com_github_tebeka_selenium") ##### Browsers dependencies ##### browser_repositories = use_extension("//web:extension.bzl", "browser_repositories_extension") + browser_repositories.install(version = "0.3.4") + use_repo( browser_repositories, "com_saucelabs_sauce_connect_linux_x64", diff --git a/README.md b/README.md index adf6569c..c0e84d03 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,14 @@ WebDriver. ## Configure your Bazel project -For all languages, you need to add the following to your MODULE.bazel file: +For each language , you need to add the following to your MODULE.bazel file: ```bzl -bazel_dep(name = "rules_webtesting", version = "0.4.0") +bazel_dep(name = "rules_webtesting_${language}", version = "0.4.0") +``` +For example for Java: +```bzl +bazel_dep(name = "rules_webtesting_java", version = "0.4.0") ``` ## Write your tests @@ -77,7 +81,7 @@ import ( "testing" "github.com/tebeka/selenium" - "github.com/bazelbuild/rules_webtesting/go/webtest" + "github.com/bazelbuild/rules_web_testing_go/webtest" ) func TestWebApp(t *testing.T) { @@ -100,7 +104,7 @@ In your BUILD files, load the correct language specific build rule and create a test target using it: ```bzl -load("@rules_webtesting//web:py.bzl", "py_web_test_suite") +load("@rules_web_testing_python//web:py.bzl", "py_web_test_suite") py_web_test_suite( name = "browser_test", diff --git a/browsers/BUILD.bazel b/browsers/BUILD.bazel index f8d5a280..ada9253b 100644 --- a/browsers/BUILD.bazel +++ b/browsers/BUILD.bazel @@ -50,9 +50,6 @@ browser( browser( name = "chromium-local", metadata = "chromium-local.json", - required_tags = [ - "native", - ], deps = [ "//go/wsl", "//third_party/chromedriver", diff --git a/go/bazel/BUILD.bazel b/go/bazel/BUILD.bazel index 2df1344b..df42180d 100644 --- a/go/bazel/BUILD.bazel +++ b/go/bazel/BUILD.bazel @@ -22,6 +22,6 @@ go_library( name = "go_default_library", srcs = ["bazel.go"], importpath = "github.com/bazelbuild/rules_webtesting/go/bazel", - visibility = ["//go:__subpackages__"], + visibility = ["//visibility:public"], deps = ["//go/cmdhelper:go_default_library"], ) diff --git a/go/metadata/BUILD.bazel b/go/metadata/BUILD.bazel index 99a5d16b..181da00e 100644 --- a/go/metadata/BUILD.bazel +++ b/go/metadata/BUILD.bazel @@ -25,7 +25,7 @@ go_library( "web_test_files.go", ], importpath = "github.com/bazelbuild/rules_webtesting/go/metadata", - visibility = ["//go:__subpackages__"], + visibility = ["//visibility:public"], deps = [ "//go/bazel:go_default_library", "//go/httphelper:go_default_library", @@ -39,7 +39,7 @@ go_test( "extension_test.go", "metadata_test.go", ], - data = ["//testdata"], + data = ["@rules_webtesting//testdata"], embed = [":go_default_library"], - deps = ["//go/bazel:go_default_library"], + deps = ["@rules_webtesting//go/bazel:go_default_library"], ) diff --git a/go/web/BUILD.bazel b/go/web/BUILD.bazel new file mode 100644 index 00000000..10e32208 --- /dev/null +++ b/go/web/BUILD.bazel @@ -0,0 +1,32 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load("@rules_webtesting//web:web.bzl", "web_test_config") + +package( + default_testonly = True, + default_visibility = ["//go:__subpackages__"], +) + +bzl_library( + name = "go", + srcs = ["go.bzl"], + deps = [ + "@rules_webtesting//web/internal:wrap_web_test_suite", + # should depend on @io_bazel_rules_go//go:def.bzl + ], +) diff --git a/web/go.bzl b/go/web/go.bzl similarity index 87% rename from web/go.bzl rename to go/web/go.bzl index 1168176e..183226b8 100644 --- a/web/go.bzl +++ b/go/web/go.bzl @@ -13,9 +13,9 @@ # limitations under the License. """Web Test rules for Go.""" -load("//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS") -load("//web/internal:wrap_web_test_suite.bzl", "wrap_web_test_suite") load("@io_bazel_rules_go//go:def.bzl", "go_test") +load("@rules_webtesting//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS") +load("@rules_webtesting//web/internal:wrap_web_test_suite.bzl", "wrap_web_test_suite") def go_web_test_suite(name, go_test_tags = DEFAULT_WRAPPED_TEST_TAGS, **kwargs): """Defines a test_suite of web_test targets that wrap a go_test target. diff --git a/go/webdriver/BUILD.bazel b/go/webdriver/BUILD.bazel index 14c71c9e..ce446db1 100644 --- a/go/webdriver/BUILD.bazel +++ b/go/webdriver/BUILD.bazel @@ -14,7 +14,7 @@ # ################################################################################ # -load("//web:go.bzl", "go_web_test_suite") +load("//go/web:go.bzl", "go_web_test_suite") load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2.0 diff --git a/go/webtest/BUILD.bazel b/go/webtest/BUILD.bazel index 7a268cf7..b4b5d474 100644 --- a/go/webtest/BUILD.bazel +++ b/go/webtest/BUILD.bazel @@ -14,7 +14,7 @@ # ################################################################################ # -load("//web:go.bzl", "go_web_test_suite") +load("//go/web:go.bzl", "go_web_test_suite") load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2.0 diff --git a/go/wtl/proxy/BUILD.bazel b/go/wtl/proxy/BUILD.bazel index bdea0d24..d6d36f54 100644 --- a/go/wtl/proxy/BUILD.bazel +++ b/go/wtl/proxy/BUILD.bazel @@ -14,7 +14,7 @@ # ################################################################################ # -load("//web:go.bzl", "go_web_test_suite") +load("//go/web:go.bzl", "go_web_test_suite") load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2.0 diff --git a/go/wtl/proxy/driverhub/quithandler/BUILD.bazel b/go/wtl/proxy/driverhub/quithandler/BUILD.bazel index 66ca5f26..e1e1b0a9 100644 --- a/go/wtl/proxy/driverhub/quithandler/BUILD.bazel +++ b/go/wtl/proxy/driverhub/quithandler/BUILD.bazel @@ -14,7 +14,7 @@ # ################################################################################ # -load("//web:go.bzl", "go_web_test_suite") +load("//go/web:go.bzl", "go_web_test_suite") load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2.0 diff --git a/go/wtl/proxy/driverhub/scripttimeout/BUILD.bazel b/go/wtl/proxy/driverhub/scripttimeout/BUILD.bazel index dfb2e78e..6908eebe 100644 --- a/go/wtl/proxy/driverhub/scripttimeout/BUILD.bazel +++ b/go/wtl/proxy/driverhub/scripttimeout/BUILD.bazel @@ -14,7 +14,7 @@ # ################################################################################ # -load("//web:go.bzl", "go_web_test_suite") +load("//go/web:go.bzl", "go_web_test_suite") load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2.0 diff --git a/requirements.in b/requirements.in deleted file mode 100644 index 72e055f5..00000000 --- a/requirements.in +++ /dev/null @@ -1 +0,0 @@ -selenium==4.27.1 diff --git a/testdata/BUILD.bazel b/testdata/BUILD.bazel index cdaac083..4b8a3994 100644 --- a/testdata/BUILD.bazel +++ b/testdata/BUILD.bazel @@ -23,7 +23,7 @@ licenses(["notice"]) # Apache 2.0 filegroup( name = "testdata", srcs = glob(["*"]), - visibility = ["//:__subpackages__"], + visibility = ["//visibility:public"], ) web_test_files( diff --git a/web/BUILD.bazel b/web/BUILD.bazel index 6b5e9ae1..3c2c08ec 100644 --- a/web/BUILD.bazel +++ b/web/BUILD.bazel @@ -29,45 +29,15 @@ web_test_config( visibility = ["//visibility:public"], ) -bzl_library( - name = "go", - srcs = ["go.bzl"], - deps = [ - "//web/internal:wrap_web_test_suite", - # should depend on @io_bazel_rules_go//go:def.bzl - ], -) - -bzl_library( - name = "java", - srcs = ["java.bzl"], - deps = ["//web/internal:wrap_web_test_suite"], -) - -bzl_library( - name = "py", - srcs = ["py.bzl"], - deps = ["//web/internal:wrap_web_test_suite"], -) - -bzl_library( - name = "scala", - srcs = ["scala.bzl"], - deps = [ - "//web/internal:wrap_web_test_suite", - # should depend on @io_bazel_rules_scala//scala:scala.bzl - ], -) - bzl_library( name = "web", srcs = ["web.bzl"], deps = [ "//web/internal:browser", "//web/internal:constants", - "//web/internal:platform_metadata", - "//web/internal:platform_archive", "//web/internal:custom_browser", + "//web/internal:platform_archive", + "//web/internal:platform_metadata", "//web/internal:web_test", "//web/internal:web_test_config", "//web/internal:web_test_files", diff --git a/web/internal/BUILD.bazel b/web/internal/BUILD.bazel index d92ea949..582fef40 100644 --- a/web/internal/BUILD.bazel +++ b/web/internal/BUILD.bazel @@ -18,7 +18,7 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") package( default_testonly = True, - default_visibility = ["//web:__subpackages__"], + default_visibility = ["//visibility:public"], ) licenses(["notice"]) # Apache 2.0 diff --git a/web_testing_go/BUILD.bazel b/web_testing_go/BUILD.bazel new file mode 100644 index 00000000..ab52bbb1 --- /dev/null +++ b/web_testing_go/BUILD.bazel @@ -0,0 +1,26 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# +load("@bazel_gazelle//:def.bzl", "gazelle") + +licenses(["notice"]) # Apache 2.0 + +exports_files(["LICENSE"]) + +gazelle( + name = "gazelle", + prefix = "github.com/bazelbuild/rules_webtesting", +) diff --git a/web_testing_go/MODULE.bazel b/web_testing_go/MODULE.bazel new file mode 100644 index 00000000..ef80b9bf --- /dev/null +++ b/web_testing_go/MODULE.bazel @@ -0,0 +1,33 @@ +module( + name = "rules_web_testing_go", + version = "0.4.0", +) + +bazel_dep( + name = "rules_webtesting", +) + +local_path_override( + module_name = "rules_webtesting", + path = "..", +) + +bazel_dep( + name = "bazel_skylib", + version = "1.7.1", +) + +bazel_dep( + name = "rules_go", + version = "0.51.0-rc1", + repo_name = "io_bazel_rules_go", +) + +bazel_dep(name = "gazelle", version = "0.42.0", repo_name = "bazel_gazelle") + +go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps") + +go_deps.from_file(go_mod = "@rules_webtesting//:go.mod") + +# All *direct* Go dependencies of the module have to be listed explicitly. +use_repo(go_deps, "com_github_gorilla_mux", "com_github_tebeka_selenium") \ No newline at end of file diff --git a/web_testing_go/testdata/BUILD b/web_testing_go/testdata/BUILD new file mode 100644 index 00000000..28431762 --- /dev/null +++ b/web_testing_go/testdata/BUILD @@ -0,0 +1,26 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# + +package(default_testonly = True) + +licenses(["notice"]) # Apache 2.0 + +filegroup( + name = "testdata", + srcs = glob(["*"]), + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/web_testing_go/testdata/all-fields.json b/web_testing_go/testdata/all-fields.json new file mode 120000 index 00000000..1dd3b8eb --- /dev/null +++ b/web_testing_go/testdata/all-fields.json @@ -0,0 +1 @@ +../../testdata/all-fields.json \ No newline at end of file diff --git a/web_testing_go/web/BUILD.bazel b/web_testing_go/web/BUILD.bazel new file mode 120000 index 00000000..f6298d4c --- /dev/null +++ b/web_testing_go/web/BUILD.bazel @@ -0,0 +1 @@ +../../go/web/BUILD.bazel \ No newline at end of file diff --git a/web_testing_go/web/go.bzl b/web_testing_go/web/go.bzl new file mode 120000 index 00000000..821f7f6d --- /dev/null +++ b/web_testing_go/web/go.bzl @@ -0,0 +1 @@ +../../go/web/go.bzl \ No newline at end of file diff --git a/web_testing_go/webtest/BUILD.bazel b/web_testing_go/webtest/BUILD.bazel new file mode 100644 index 00000000..ce882d9c --- /dev/null +++ b/web_testing_go/webtest/BUILD.bazel @@ -0,0 +1,49 @@ +# Copyright 2017 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# +load("//web:go.bzl", "go_web_test_suite") +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +licenses(["notice"]) # Apache 2.0 + +go_library( + name = "go_default_library", + srcs = ["webtest.go"], + importpath = "github.com/bazelbuild/rules_webtesting/web_testing_go/webtest", + visibility = ["//visibility:public"], + deps = [ + "@rules_webtesting//go/bazel:go_default_library", + "@rules_webtesting//go/metadata:go_default_library", + "@com_github_tebeka_selenium//:go_default_library", + ], +) + +go_web_test_suite( + name = "go_default_test", + srcs = [ + "browserinfo_test.go", + "webtest_test.go", + ], + browsers = [ + "@rules_webtesting//browsers:chromium-local", + "@rules_webtesting//browsers:firefox-local", + "@rules_webtesting//browsers/sauce:chrome-win10", + "@rules_webtesting//browsers/sauce:chrome-win10-connect", + ], + data = ["//testdata"], + embed = [":go_default_library"], + deps = ["@com_github_tebeka_selenium//:go_default_library"], +) diff --git a/web_testing_go/webtest/browserinfo_test.go b/web_testing_go/webtest/browserinfo_test.go new file mode 120000 index 00000000..22fad2ea --- /dev/null +++ b/web_testing_go/webtest/browserinfo_test.go @@ -0,0 +1 @@ +../../go/webtest/browserinfo_test.go \ No newline at end of file diff --git a/web_testing_go/webtest/webtest.go b/web_testing_go/webtest/webtest.go new file mode 120000 index 00000000..080357e1 --- /dev/null +++ b/web_testing_go/webtest/webtest.go @@ -0,0 +1 @@ +../../go/webtest/webtest.go \ No newline at end of file diff --git a/web_testing_go/webtest/webtest_test.go b/web_testing_go/webtest/webtest_test.go new file mode 120000 index 00000000..acabea0e --- /dev/null +++ b/web_testing_go/webtest/webtest_test.go @@ -0,0 +1 @@ +../../go/webtest/webtest_test.go \ No newline at end of file diff --git a/web_testing_java/BUILD.bazel b/web_testing_java/BUILD.bazel new file mode 100644 index 00000000..e69de29b diff --git a/web_testing_java/MODULE.bazel b/web_testing_java/MODULE.bazel new file mode 100644 index 00000000..8e7f6b39 --- /dev/null +++ b/web_testing_java/MODULE.bazel @@ -0,0 +1,36 @@ +module( + name = "rules_web_testing_java", + version = "0.4.0", +) + +bazel_dep( + name = "rules_webtesting", +) + +local_path_override( + module_name = "rules_webtesting", + path = "..", +) + +bazel_dep( + name = "bazel_skylib", + version = "1.7.1", +) + +bazel_dep( + name = "rules_jvm_external", + version = "6.6", +) + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") + +maven.install( + artifacts = [ + "com.google.guava:guava:33.2.1-jre", + "org.seleniumhq.selenium:selenium-remote-driver:4.27.0", + "org.seleniumhq.selenium:selenium-api:4.27.0", + "junit:junit:4.13.2", + ], +) + +use_repo(maven, "maven") diff --git a/java/com/google/testing/bazel/BUILD.bazel b/web_testing_java/java/com/google/testing/bazel/BUILD.bazel similarity index 100% rename from java/com/google/testing/bazel/BUILD.bazel rename to web_testing_java/java/com/google/testing/bazel/BUILD.bazel diff --git a/java/com/google/testing/bazel/Bazel.java b/web_testing_java/java/com/google/testing/bazel/Bazel.java similarity index 100% rename from java/com/google/testing/bazel/Bazel.java rename to web_testing_java/java/com/google/testing/bazel/Bazel.java diff --git a/java/com/google/testing/web/BUILD.bazel b/web_testing_java/java/com/google/testing/web/BUILD.bazel similarity index 100% rename from java/com/google/testing/web/BUILD.bazel rename to web_testing_java/java/com/google/testing/web/BUILD.bazel diff --git a/java/com/google/testing/web/WebTest.java b/web_testing_java/java/com/google/testing/web/WebTest.java similarity index 100% rename from java/com/google/testing/web/WebTest.java rename to web_testing_java/java/com/google/testing/web/WebTest.java diff --git a/javatests/com/google/testing/web/BUILD.bazel b/web_testing_java/javatests/com/google/testing/web/BUILD.bazel similarity index 81% rename from javatests/com/google/testing/web/BUILD.bazel rename to web_testing_java/javatests/com/google/testing/web/BUILD.bazel index 7499d4c4..3cddeb79 100644 --- a/javatests/com/google/testing/web/BUILD.bazel +++ b/web_testing_java/javatests/com/google/testing/web/BUILD.bazel @@ -22,10 +22,10 @@ java_web_test_suite( name = "WebTestTest", srcs = ["WebTestTest.java"], browsers = [ - "//browsers:chromium-local", - "//browsers:firefox-local", - "//browsers/sauce:chrome-win10", - "//browsers/sauce:chrome-win10-connect", + "@rules_webtesting//browsers:chromium-local", + "@rules_webtesting//browsers:firefox-local", + "@rules_webtesting//browsers/sauce:chrome-win10", + "@rules_webtesting//browsers/sauce:chrome-win10-connect", ], deps = [ "//java/com/google/testing/web", diff --git a/javatests/com/google/testing/web/WebTestTest.java b/web_testing_java/javatests/com/google/testing/web/WebTestTest.java similarity index 100% rename from javatests/com/google/testing/web/WebTestTest.java rename to web_testing_java/javatests/com/google/testing/web/WebTestTest.java diff --git a/web_testing_java/web/BUILD.bazel b/web_testing_java/web/BUILD.bazel new file mode 100644 index 00000000..bee0207f --- /dev/null +++ b/web_testing_java/web/BUILD.bazel @@ -0,0 +1,29 @@ +# Copyright 2025 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load("@rules_webtesting//web:web.bzl", "web_test_config") + +package( + default_testonly = True, + default_visibility = ["//visibility:public"], +) + +bzl_library( + name = "java", + srcs = ["java.bzl"], + deps = ["@rules_webtesting//web/internal:wrap_web_test_suite"], +) diff --git a/web/java.bzl b/web_testing_java/web/java.bzl similarity index 89% rename from web/java.bzl rename to web_testing_java/web/java.bzl index 359425ad..ecb84912 100644 --- a/web/java.bzl +++ b/web_testing_java/web/java.bzl @@ -13,8 +13,8 @@ # limitations under the License. """Web Test rules for Java.""" -load("//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS") -load("//web/internal:wrap_web_test_suite.bzl", "wrap_web_test_suite") +load("@rules_webtesting//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS") +load("@rules_webtesting//web/internal:wrap_web_test_suite.bzl", "wrap_web_test_suite") def java_web_test_suite(name, java_test_tags = DEFAULT_WRAPPED_TEST_TAGS, test_class = None, **kwargs): """Defines a test_suite of web_test targets that wrap a java_test target. diff --git a/web_testing_python/BUILD.bazel b/web_testing_python/BUILD.bazel new file mode 100644 index 00000000..b5ad4b8c --- /dev/null +++ b/web_testing_python/BUILD.bazel @@ -0,0 +1,28 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# +load("@python_versions//3.11:defs.bzl", "compile_pip_requirements") + +licenses(["notice"]) # Apache 2.0 + +exports_files(["LICENSE"]) + +compile_pip_requirements( + name = "requirements", + requirements_in = "requirements.in", + requirements_txt = "requirements_lock.txt", + requirements_windows = "requirements_lock_windows.txt", +) diff --git a/web_testing_python/MODULE.bazel b/web_testing_python/MODULE.bazel new file mode 100644 index 00000000..28f33dad --- /dev/null +++ b/web_testing_python/MODULE.bazel @@ -0,0 +1,43 @@ +module( + name = "rules_web_testing_python", + version = "0.4.0", +) + +bazel_dep( + name = "bazel_skylib", + version = "1.7.1", +) + +bazel_dep( + name = "rules_webtesting", +) + +local_path_override( + module_name = "rules_webtesting", + path = "..", +) + +bazel_dep( + name = "rules_python", + version = "1.0.0", +) + +python = use_extension("@rules_python//python/extensions:python.bzl", "python") + +python.toolchain( + is_default = True, + python_version = "3.11", +) + +use_repo(python, "python_3_11", "python_versions") + +pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") + +pip.parse( + hub_name = "rules_webtesting_py_deps", + python_version = "3.11", + requirements_lock = "//:requirements_lock.txt", + requirements_windows = "requirements_lock_windows.txt", +) + +use_repo(pip, "rules_webtesting_py_deps") diff --git a/web_testing_python/requirements.in b/web_testing_python/requirements.in new file mode 100644 index 00000000..e7021a5b --- /dev/null +++ b/web_testing_python/requirements.in @@ -0,0 +1 @@ +selenium==4.31.0 diff --git a/requirements_lock.txt b/web_testing_python/requirements_lock.txt similarity index 60% rename from requirements_lock.txt rename to web_testing_python/requirements_lock.txt index 423b3ab0..a811cf1f 100644 --- a/requirements_lock.txt +++ b/web_testing_python/requirements_lock.txt @@ -4,19 +4,19 @@ # # bazel run //:requirements.update # -attrs==24.2.0 \ - --hash=sha256:5cfb1b9148b5b086569baec03f20d7b6bf3bcacc9a42bebf87ffaaca362f6346 \ - --hash=sha256:81921eb96de3191c8258c199618104dd27ac608d9366f5e35d011eae1867ede2 +attrs==25.3.0 \ + --hash=sha256:427318ce031701fea540783410126f03899a97ffc6f61596ad581ac2e40e3bc3 \ + --hash=sha256:75d7cefc7fb576747b2c81b4442d4d4a1ce0900973527c011d1030fd3bf4af1b # via # outcome # trio -certifi==2024.8.30 \ - --hash=sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8 \ - --hash=sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9 +certifi==2025.1.31 \ + --hash=sha256:3d5da6925056f6f18f119200434a4780a94263f10d1c21d032a6f6b2baa20651 \ + --hash=sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe # via selenium -h11==0.14.0 \ - --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ - --hash=sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761 +h11==0.16.0 \ + --hash=sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1 \ + --hash=sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86 # via wsproto idna==3.10 \ --hash=sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9 \ @@ -25,15 +25,17 @@ idna==3.10 \ outcome==1.3.0.post0 \ --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b - # via trio + # via + # trio + # trio-websocket pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ --hash=sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5 \ --hash=sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0 # via urllib3 -selenium==4.27.1 \ - --hash=sha256:5296c425a75ff1b44d0d5199042b36a6d1ef76c04fb775b97b40be739a9caae2 \ - --hash=sha256:b89b1f62b5cfe8025868556fe82360d6b649d464f75d2655cb966c8f8447ea18 +selenium==4.31.0 \ + --hash=sha256:441cffc436a2e6659fe3cfb012692435652efd38b0d368d16f661a5db47825f5 \ + --hash=sha256:7b8b8d5e424d7133cb7aa656263b19ac505ec26d65c0f921a696e7e2c5ccd95b # via -r requirements.in sniffio==1.3.1 \ --hash=sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2 \ @@ -43,19 +45,19 @@ sortedcontainers==2.4.0 \ --hash=sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88 \ --hash=sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0 # via trio -trio==0.27.0 \ - --hash=sha256:1dcc95ab1726b2da054afea8fd761af74bad79bd52381b84eae408e983c76831 \ - --hash=sha256:68eabbcf8f457d925df62da780eff15ff5dc68fd6b367e2dde59f7aaf2a0b884 +trio==0.30.0 \ + --hash=sha256:0781c857c0c81f8f51e0089929a26b5bb63d57f927728a5586f7e36171f064df \ + --hash=sha256:3bf4f06b8decf8d3cf00af85f40a89824669e2d033bb32469d34840edcfc22a5 # via # selenium # trio-websocket -trio-websocket==0.11.1 \ - --hash=sha256:18c11793647703c158b1f6e62de638acada927344d534e3c7628eedcb746839f \ - --hash=sha256:520d046b0d030cf970b8b2b2e00c4c2245b3807853ecd44214acd33d74581638 +trio-websocket==0.12.2 \ + --hash=sha256:22c72c436f3d1e264d0910a3951934798dcc5b00ae56fc4ee079d46c7cf20fae \ + --hash=sha256:df605665f1db533f4a386c94525870851096a223adcb97f72a07e8b4beba45b6 # via selenium -typing-extensions==4.12.2 \ - --hash=sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d \ - --hash=sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8 +typing-extensions==4.13.2 \ + --hash=sha256:a439e7c04b49fec3e5d3e2beaa21755cadbbdc391694e28ccdd36ca4a1408f8c \ + --hash=sha256:e6c81219bd689f51865d9e372991c540bda33a0379d5573cddb9a3a23f7caaef # via selenium urllib3[socks]==2.2.3 \ --hash=sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac \ diff --git a/requirements_lock_windows.txt b/web_testing_python/requirements_lock_windows.txt similarity index 97% rename from requirements_lock_windows.txt rename to web_testing_python/requirements_lock_windows.txt index d94eee74..7d4729b2 100644 --- a/requirements_lock_windows.txt +++ b/web_testing_python/requirements_lock_windows.txt @@ -104,9 +104,9 @@ pysocks==1.7.1 \ --hash=sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5 \ --hash=sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0 # via urllib3 -selenium==4.27.1 \ - --hash=sha256:5296c425a75ff1b44d0d5199042b36a6d1ef76c04fb775b97b40be739a9caae2 \ - --hash=sha256:b89b1f62b5cfe8025868556fe82360d6b649d464f75d2655cb966c8f8447ea18 +selenium==4.31.0 \ + --hash=sha256:441cffc436a2e6659fe3cfb012692435652efd38b0d368d16f661a5db47825f5 \ + --hash=sha256:7b8b8d5e424d7133cb7aa656263b19ac505ec26d65c0f921a696e7e2c5ccd95b # via -r requirements.in sniffio==1.3.1 \ --hash=sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2 \ diff --git a/testing/web/BUILD.bazel b/web_testing_python/testing/web/BUILD.bazel similarity index 84% rename from testing/web/BUILD.bazel rename to web_testing_python/testing/web/BUILD.bazel index 6c563197..d14447e8 100644 --- a/testing/web/BUILD.bazel +++ b/web_testing_python/testing/web/BUILD.bazel @@ -35,14 +35,16 @@ py_web_test_suite( name = "webtest_test", srcs = ["webtest_test.py"], browsers = [ - "//browsers:chromium-local", - "//browsers:firefox-local", - "//browsers/sauce:chrome-win10", - "//browsers/sauce:chrome-win10-connect", + "@rules_webtesting//browsers:chromium-local", + "@rules_webtesting//browsers:firefox-local", + "@rules_webtesting//browsers/sauce:chrome-win10", + "@rules_webtesting//browsers/sauce:chrome-win10-connect", ], tags = { "chromium-local": [ "native", + "sauce", + "notravis", ], "chrome-win10": [ "exclusive", diff --git a/testing/web/debugger/BUILD.bazel b/web_testing_python/testing/web/debugger/BUILD similarity index 100% rename from testing/web/debugger/BUILD.bazel rename to web_testing_python/testing/web/debugger/BUILD diff --git a/testing/web/debugger/debugger.py b/web_testing_python/testing/web/debugger/debugger.py similarity index 100% rename from testing/web/debugger/debugger.py rename to web_testing_python/testing/web/debugger/debugger.py diff --git a/testing/web/webtest.py b/web_testing_python/testing/web/webtest.py similarity index 73% rename from testing/web/webtest.py rename to web_testing_python/testing/web/webtest.py index 5e3fd490..7c2f563e 100644 --- a/testing/web/webtest.py +++ b/web_testing_python/testing/web/webtest.py @@ -24,8 +24,9 @@ """ import os -from selenium.webdriver.remote import remote_connection -from selenium.webdriver.remote import webdriver +from selenium import webdriver +from selenium.webdriver.remote.client_config import ClientConfig +from selenium.webdriver.remote.remote_connection import RemoteConnection def new_webdriver_session(capabilities=None): @@ -39,14 +40,20 @@ def new_webdriver_session(capabilities=None): A new WebDriver connected to a browser defined by the web test environment. """ - capabilities = capabilities or {} + os.environ["LANG"] = "en_US.UTF-8" address = os.environ['WEB_TEST_WEBDRIVER_SERVER'].rstrip('/') - # Set the timeout for WebDriver http requests so that the socket default # timeout is not used. - remote_connection.RemoteConnection.set_timeout(450) + client_config = ClientConfig(remote_server_addr=address, timeout=450) + executor = RemoteConnection( + client_config=client_config, + ) - return webdriver.WebDriver(address, desired_capabilities=capabilities) + # options = webdriver.ChromeOptions() + options = webdriver.FirefoxOptions() + options.add_argument('--headless') + options.add_argument("--no-sandbox") + return webdriver.Remote(command_executor=executor, options=options) def http_address(): diff --git a/testing/web/webtest_test.py b/web_testing_python/testing/web/webtest_test.py similarity index 100% rename from testing/web/webtest_test.py rename to web_testing_python/testing/web/webtest_test.py diff --git a/web_testing_python/web/BUILD.bazel b/web_testing_python/web/BUILD.bazel new file mode 100644 index 00000000..f17000e8 --- /dev/null +++ b/web_testing_python/web/BUILD.bazel @@ -0,0 +1,29 @@ +# Copyright 2025 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load("@rules_webtesting//web:web.bzl", "web_test_config") + +package( + default_testonly = True, + default_visibility = ["//visibility:public"], +) + +bzl_library( + name = "py", + srcs = ["py.bzl"], + deps = ["@rules_webtesting//web/internal:wrap_web_test_suite"], +) diff --git a/web/py.bzl b/web_testing_python/web/py.bzl similarity index 87% rename from web/py.bzl rename to web_testing_python/web/py.bzl index 104e7c41..3a641736 100644 --- a/web/py.bzl +++ b/web_testing_python/web/py.bzl @@ -13,8 +13,8 @@ # limitations under the License. """Web Test rules for Python.""" -load("//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS") -load("//web/internal:wrap_web_test_suite.bzl", "wrap_web_test_suite") +load("@rules_webtesting//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS") +load("@rules_webtesting//web/internal:wrap_web_test_suite.bzl", "wrap_web_test_suite") def py_web_test_suite(name, py_test_tags = DEFAULT_WRAPPED_TEST_TAGS, main = None, **kwargs): """Defines a test_suite of web_test targets that wrap a py_test target. diff --git a/web_testing_scala/MODULE.bazel b/web_testing_scala/MODULE.bazel new file mode 100644 index 00000000..e9f16d34 --- /dev/null +++ b/web_testing_scala/MODULE.bazel @@ -0,0 +1,74 @@ +module( + name = "rules_web_testing_scala", + version = "0.4.0", +) + +bazel_dep( + name = "rules_webtesting", +) + +local_path_override( + module_name = "rules_webtesting", + path = "..", +) + +bazel_dep( + name = "rules_web_testing_java", +) + + +local_path_override( + module_name = "rules_web_testing_java", + path = "../web_testing_java", +) + +bazel_dep( + name = "bazel_skylib", + version = "1.7.1", +) + +##### Scala dependencies ##### +bazel_dep( + name = "rules_scala", + repo_name = "io_bazel_rules_scala", +) + +# TODO: Switch to a release version once it's available in BCR. +# Otherwise, the root module has to declare the same override. +git_override( + module_name = "rules_scala", + commit = "219e63983e8e483e66ebf70372969ba227382001", + remote = "https://github.com/mbland/rules_scala", +) + +scala_deps = use_extension( + "@io_bazel_rules_scala//scala/extensions:deps.bzl", + "scala_deps", +) + +scala_deps.settings( + fetch_sources = True, +) + +scala_deps.toolchains( + scalatest = True, +) + +##### Java dependencies ##### +bazel_dep( + name = "rules_jvm_external", + version = "6.6", +) + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") + +maven.install( + artifacts = [ + "com.google.guava:guava:33.2.1-jre", + "org.seleniumhq.selenium:selenium-remote-driver:4.27.0", + "org.seleniumhq.selenium:selenium-api:4.27.0", + "junit:junit:4.13.2", + ], +) + +use_repo(maven, "maven") diff --git a/scalatests/com/google/testing/web/BUILD.bazel b/web_testing_scala/scalatests/BUILD.bazel similarity index 76% rename from scalatests/com/google/testing/web/BUILD.bazel rename to web_testing_scala/scalatests/BUILD.bazel index a7b7c5c0..b4cee0d7 100644 --- a/scalatests/com/google/testing/web/BUILD.bazel +++ b/web_testing_scala/scalatests/BUILD.bazel @@ -22,14 +22,14 @@ scala_web_test_suite( name = "WebTestTest", srcs = ["WebTestTest.scala"], browsers = [ - "//browsers:chromium-local", - "//browsers:firefox-local", - "//browsers/sauce:chrome-win10", - "//browsers/sauce:chrome-win10-connect", + "@rules_webtesting//browsers:chromium-local", + "@rules_webtesting//browsers:firefox-local", + "@rules_webtesting//browsers/sauce:chrome-win10", + "@rules_webtesting//browsers/sauce:chrome-win10-connect", ], deps = [ - "//java/com/google/testing/web", "@maven//:junit_junit", "@maven//:org_seleniumhq_selenium_selenium_api", + "@rules_web_testing_java//java/com/google/testing/web", ], ) diff --git a/scalatests/com/google/testing/web/WebTestTest.scala b/web_testing_scala/scalatests/WebTestTest.scala similarity index 100% rename from scalatests/com/google/testing/web/WebTestTest.scala rename to web_testing_scala/scalatests/WebTestTest.scala diff --git a/web_testing_scala/web/BUILD.bazel b/web_testing_scala/web/BUILD.bazel new file mode 100644 index 00000000..ad48c48b --- /dev/null +++ b/web_testing_scala/web/BUILD.bazel @@ -0,0 +1,32 @@ +# Copyright 2025 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load("@rules_webtesting//web:web.bzl", "web_test_config") + +package( + default_testonly = True, + default_visibility = ["//visibility:public"], +) + +bzl_library( + name = "scala", + srcs = ["scala.bzl"], + deps = [ + "@rules_webtesting//web/internal:wrap_web_test_suite", + # should depend on @io_bazel_rules_scala//scala:scala.bzl + ], +) diff --git a/web/scala.bzl b/web_testing_scala/web/scala.bzl similarity index 87% rename from web/scala.bzl rename to web_testing_scala/web/scala.bzl index 19e2ea27..b78ec7e7 100644 --- a/web/scala.bzl +++ b/web_testing_scala/web/scala.bzl @@ -13,9 +13,9 @@ # limitations under the License. """Web Test rules for Java.""" -load("//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS") -load("//web/internal:wrap_web_test_suite.bzl", "wrap_web_test_suite") load("@io_bazel_rules_scala//scala:scala.bzl", "scala_test") +load("@rules_webtesting//web/internal:constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS") +load("@rules_webtesting//web/internal:wrap_web_test_suite.bzl", "wrap_web_test_suite") def scala_web_test_suite(name, scala_test_tags = DEFAULT_WRAPPED_TEST_TAGS, **kwargs): """Defines a test_suite of web_test targets that wrap a java_test target.