diff --git a/.github/workflows/ci-ruby.yml b/.github/workflows/ci-ruby.yml index deb56b656f4c0..653034f947f45 100644 --- a/.github/workflows/ci-ruby.yml +++ b/.github/workflows/ci-ruby.yml @@ -87,11 +87,6 @@ jobs: os: ubuntu - browser: safari os: windows - # TODO: Investigate why they are timing out - - browser: chrome - os: windows - - browser: edge - os: windows with: name: Local Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }} diff --git a/MODULE.bazel b/MODULE.bazel index 93578f833b573..d8249a99f7121 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -124,16 +124,6 @@ use_repo(pip, "py_dev_requirements") register_toolchains("@pythons_hub//:all") -# https://github.com/bazelbuild/rules_jvm_external/pull/1079 -archive_override( - module_name = "rules_jvm_external", - integrity = "sha256-yS8Qes1PLbYbe10b1WSgl0Auqn/1Wlxg8O3wSr7a/Sg=", - patch_strip = 1, - patches = ["//java:rules_jvm_external_javadoc.patch"], - strip_prefix = "rules_jvm_external-f572a26116c7ef71d8842dd056c2605782f7be8d", - urls = ["https://github.com/bazelbuild/rules_jvm_external/archive/f572a26116c7ef71d8842dd056c2605782f7be8d.tar.gz"], -) - java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") use_repo( java_toolchains, diff --git a/README.md b/README.md index d2b905c8108f9..6ebfda3fbf20f 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,6 @@ Supported browsers: * `safari-preview` In addition to the [Common Options Examples](#common-options-examples), here are some additional Ruby specific ones: -* `--test_arg "-tfocus"` - test only [focused specs](https://relishapp.com/rspec/rspec-core/v/3-12/docs/filtering/inclusion-filters) * `--test_arg "-eTimeouts"` - test only specs which name include "Timeouts" * `--test_arg ""` - pass any extra RSpec arguments (see `bazel run @bundle//bin:rspec -- --help`) diff --git a/common/repositories.bzl b/common/repositories.bzl index adfa7e84f4f72..bc71b842c4616 100644 --- a/common/repositories.bzl +++ b/common/repositories.bzl @@ -50,8 +50,8 @@ js_library( http_archive( name = "linux_beta_firefox", - url = "https://ftp.mozilla.org/pub/firefox/releases/126.0b7/linux-x86_64/en-US/firefox-126.0b7.tar.bz2", - sha256 = "a7bd26d05857ffb08e46af9016973c74d16be806025a6329bb843dffde0672f9", + url = "https://ftp.mozilla.org/pub/firefox/releases/126.0b8/linux-x86_64/en-US/firefox-126.0b8.tar.bz2", + sha256 = "75198959b1eeedc81be229ad3066ee6d49ecde985ce5d5d11d61f0914e288517", build_file_content = """ load("@aspect_rules_js//js:defs.bzl", "js_library") package(default_visibility = ["//visibility:public"]) @@ -72,8 +72,8 @@ js_library( dmg_archive( name = "mac_beta_firefox", - url = "https://ftp.mozilla.org/pub/firefox/releases/126.0b7/mac/en-US/Firefox%20126.0b7.dmg", - sha256 = "f98f772c94addfb05f2c1abe851938b2f806794af0104c73d51445132fa0855c", + url = "https://ftp.mozilla.org/pub/firefox/releases/126.0b8/mac/en-US/Firefox%20126.0b8.dmg", + sha256 = "ca247dbfa1b092f36c75ab785acb0c54e608545b76dc06fbac9a9034df0daf8a", build_file_content = """ load("@aspect_rules_js//js:defs.bzl", "js_library") package(default_visibility = ["//visibility:public"]) diff --git a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java index 6f282607c7166..7a87460878313 100644 --- a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java +++ b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java @@ -347,13 +347,16 @@ public Optional maybeGetDevTools() { } private Optional createBiDi(Optional biDiUri) { - if (!biDiUri.isPresent()) { + if (biDiUri.isEmpty()) { return Optional.empty(); } URI wsUri = biDiUri.orElseThrow( - () -> new BiDiException("This version of Chromium driver does not support BiDi")); + () -> + new BiDiException( + "Check if this browser version supports BiDi and if the 'webSocketUrl: true'" + + " capability is set.")); HttpClient.Factory clientFactory = HttpClient.Factory.createDefault(); ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri); diff --git a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java index 36111d411c9a0..1745564ffdaf8 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java @@ -354,14 +354,16 @@ public DevTools getDevTools() { } private Optional createBiDi(Optional biDiUri) { - if (!biDiUri.isPresent()) { + if (biDiUri.isEmpty()) { return Optional.empty(); } URI wsUri = biDiUri.orElseThrow( () -> - new BiDiException("This version of Firefox or geckodriver does not support BiDi")); + new BiDiException( + "Check if this browser version supports BiDi and if the 'webSocketUrl: true'" + + " capability is set.")); HttpClient.Factory clientFactory = HttpClient.Factory.createDefault(); ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri); @@ -380,8 +382,10 @@ public Optional maybeGetBiDi() { @Override public BiDi getBiDi() { - if (!biDiUri.isPresent()) { - throw new BiDiException("This version of Firefox or geckodriver does not support Bidi"); + if (biDiUri.isEmpty()) { + throw new BiDiException( + "Check if this browser version supports BiDi and if the 'webSocketUrl: true' capability" + + " is set."); } return maybeGetBiDi() diff --git a/rb/lib/selenium/server.rb b/rb/lib/selenium/server.rb index 560bc4e851c16..7d031f26af07d 100644 --- a/rb/lib/selenium/server.rb +++ b/rb/lib/selenium/server.rb @@ -183,6 +183,7 @@ def download_server(uri, destination) def initialize(jar, opts = {}) raise Errno::ENOENT, jar unless File.exist?(jar) + @java = opts.fetch(:java, 'java') @jar = jar @host = '127.0.0.1' @role = opts.fetch(:role, 'standalone') @@ -241,7 +242,7 @@ def process # extract any additional_args that start with -D as options properties = @additional_args.dup - @additional_args.delete_if { |arg| arg[/^-D/] } args = ['-jar', @jar, @role, '--port', @port.to_s] - server_command = ['java'] + properties + args + @additional_args + server_command = [@java] + properties + args + @additional_args cp = WebDriver::ChildProcess.build(*server_command) if @log.is_a?(String) diff --git a/rb/spec/BUILD.bazel b/rb/spec/BUILD.bazel index 57d8b4fecaa72..5c65b738fc997 100644 --- a/rb/spec/BUILD.bazel +++ b/rb/spec/BUILD.bazel @@ -117,3 +117,12 @@ rb_library( "//rb/spec/unit/selenium/webdriver/support:select", ], ) + +genrule( + name = "java-location", + srcs = [], + outs = ["java-location.txt"], + cmd = "echo $(JAVA) > $@", + toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"], + visibility = ["//rb/spec:__subpackages__"], +) diff --git a/rb/spec/integration/selenium/webdriver/spec_helper.rb b/rb/spec/integration/selenium/webdriver/spec_helper.rb index 013bd8c65c791..bf0a507577ef1 100644 --- a/rb/spec/integration/selenium/webdriver/spec_helper.rb +++ b/rb/spec/integration/selenium/webdriver/spec_helper.rb @@ -45,7 +45,9 @@ GlobalTestEnv.quit_driver end - c.filter_run focus: true if ENV['focus'] + c.filter_run_when_matching :focus + c.run_all_when_everything_filtered = true + c.default_formatter = c.files_to_run.count > 1 ? 'progress' : 'doc' c.before do |example| guards = WebDriver::Support::Guards.new(example, bug_tracker: 'https://github.com/SeleniumHQ/selenium/issues') diff --git a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb index 49c29177b0d1b..aafa63bcd17bb 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb @@ -87,6 +87,7 @@ def app_server def remote_server @remote_server ||= Selenium::Server.new( remote_server_jar, + java: bazel_java, port: random_port, log_level: WebDriver.logger.debug? && 'FINE', background: true, @@ -95,6 +96,12 @@ def remote_server ) end + def bazel_java + return unless ENV.key?('WD_BAZEL_JAVA_LOCATION') + + File.expand_path(File.read(File.expand_path(ENV.fetch('WD_BAZEL_JAVA_LOCATION'))).chomp) + end + def reset_remote_server @remote_server&.stop @remote_server = nil @@ -243,7 +250,7 @@ def safari_preview_driver(**opts) def chrome_options(args: [], **opts) opts[:binary] ||= ENV['CHROME_BINARY'] if ENV.key?('CHROME_BINARY') args << '--headless=chrome' if ENV['HEADLESS'] - args << '--no-sandbox' + args << '--no-sandbox' if ENV['NO_SANDBOX'] args << '--disable-gpu' WebDriver::Options.chrome(browser_version: 'stable', args: args, **opts) end @@ -251,7 +258,7 @@ def chrome_options(args: [], **opts) def edge_options(args: [], **opts) opts[:binary] ||= ENV['EDGE_BINARY'] if ENV.key?('EDGE_BINARY') args << '--headless=chrome' if ENV['HEADLESS'] - args << '--no-sandbox' + args << '--no-sandbox' if ENV['NO_SANDBOX'] args << '--disable-gpu' WebDriver::Options.edge(browser_version: 'stable', args: args, **opts) end diff --git a/rb/spec/integration/selenium/webdriver/window_spec.rb b/rb/spec/integration/selenium/webdriver/window_spec.rb index 3b820f801be75..5d01db255da4a 100644 --- a/rb/spec/integration/selenium/webdriver/window_spec.rb +++ b/rb/spec/integration/selenium/webdriver/window_spec.rb @@ -124,8 +124,7 @@ module WebDriver expect(new_size.height).to be > old_size.height end - it 'can minimize the window', except: [{browser: %i[chrome edge], headless: true}, - {browser: :safari, ci: :github}], + it 'can minimize the window', except: [{browser: %i[chrome edge], headless: true}], flaky: {browser: :chrome, platform: %i[macosx linux], ci: :github} do window.minimize expect { diff --git a/rb/spec/tests.bzl b/rb/spec/tests.bzl index 809d62c714fd2..9c0f1596de6e9 100644 --- a/rb/spec/tests.bzl +++ b/rb/spec/tests.bzl @@ -30,6 +30,9 @@ BROWSERS = { }) | select({ "@selenium//common:use_headless_browser": {"HEADLESS": "true"}, "//conditions:default": {}, + }) | select({ + "@platforms//os:windows": {}, + "//conditions:default": {"NO_SANDBOX": "true"}, }), }, "edge": { @@ -53,6 +56,9 @@ BROWSERS = { }) | select({ "@selenium//common:use_headless_browser": {"HEADLESS": "true"}, "//conditions:default": {}, + }) | select({ + "@platforms//os:windows": {}, + "//conditions:default": {"NO_SANDBOX": "true"}, }), }, "firefox": { @@ -174,8 +180,13 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke 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_SPEC_DRIVER": "remote"}, + 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), diff --git a/rb/spec/unit/selenium/webdriver/spec_helper.rb b/rb/spec/unit/selenium/webdriver/spec_helper.rb index 94badd92264e5..cb6cf23d9b00d 100644 --- a/rb/spec/unit/selenium/webdriver/spec_helper.rb +++ b/rb/spec/unit/selenium/webdriver/spec_helper.rb @@ -58,7 +58,9 @@ def with_env(hash) c.include Selenium::WebDriver::UnitSpecHelper - c.filter_run focus: true if ENV['focus'] + c.filter_run_when_matching :focus + c.run_all_when_everything_filtered = true + c.default_formatter = c.files_to_run.count > 1 ? 'progress' : 'doc' c.before do # https://github.com/ruby/debug/issues/797