Skip to content

Commit

Permalink
Merge branch 'trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol authored May 2, 2024
2 parents c698382 + 5d4cfc1 commit 3ffe326
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 34 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
10 changes: 0 additions & 10 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<any other RSpec argument>"` - pass any extra RSpec arguments (see `bazel run @bundle//bin:rspec -- --help`)

Expand Down
8 changes: 4 additions & 4 deletions common/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -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"])
Expand Down
7 changes: 5 additions & 2 deletions java/src/org/openqa/selenium/chromium/ChromiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,16 @@ public Optional<DevTools> maybeGetDevTools() {
}

private Optional<BiDi> createBiDi(Optional<URI> 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);
Expand Down
12 changes: 8 additions & 4 deletions java/src/org/openqa/selenium/firefox/FirefoxDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,16 @@ public DevTools getDevTools() {
}

private Optional<BiDi> createBiDi(Optional<URI> 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);
Expand All @@ -380,8 +382,10 @@ public Optional<BiDi> 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()
Expand Down
3 changes: 2 additions & 1 deletion rb/lib/selenium/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions rb/spec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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__"],
)
4 changes: 3 additions & 1 deletion rb/spec/integration/selenium/webdriver/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -243,15 +250,15 @@ 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

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
Expand Down
3 changes: 1 addition & 2 deletions rb/spec/integration/selenium/webdriver/window_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 12 additions & 1 deletion rb/spec/tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion rb/spec/unit/selenium/webdriver/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ffe326

Please sign in to comment.