Skip to content

Commit

Permalink
[rb] Ensure server is started with Bazel JDK
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Apr 26, 2024
1 parent f2b6813 commit a57778f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions rb/lib/selenium/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,12 @@ def process
@process ||= begin
# 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
args = [@role, '--port', @port.to_s]
if ENV.key?('SELENIUM_BAZEL_SERVER_LAUNCHER')
server_command = [ENV['SELENIUM_BAZEL_SERVER_LAUNCHER']] + properties + args + @additional_args
else
server_command = ['java'] + properties + ['-jar', @jar] + args + @additional_args
end
cp = WebDriver::ChildProcess.build(*server_command)

if @log.is_a?(String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def initialize
@driver = ENV.fetch('WD_SPEC_DRIVER', 'chrome').tr('-', '_').to_sym
@driver_instance = nil
@remote_server = nil

if ENV.key?('SELENIUM_BAZEL_SERVER_LAUNCHER')
ENV['SELENIUM_BAZEL_SERVER_LAUNCHER'] = ENV.fetch('SELENIUM_BAZEL_SERVER_LAUNCHER', '').split(' ').first
end
end

def print_env
Expand Down
7 changes: 5 additions & 2 deletions rb/spec/tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,12 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
args = ["rb/spec/"],
data = BROWSERS[browser]["data"] + data + [
"//common/src/web",
"//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar",
"//java/src/org/openqa/selenium/grid:selenium_server",
],
env = BROWSERS[browser]["env"] | {"WD_SPEC_DRIVER": "remote"},
env = BROWSERS[browser]["env"] | {
"SELENIUM_BAZEL_SERVER_LAUNCHER": "'$(rootpaths //java/src/org/openqa/selenium/grid:selenium_server)'",
"WD_SPEC_DRIVER": "remote",
},
main = "@bundle//bin:rspec",
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + [
"{}-remote".format(browser),
Expand Down

0 comments on commit a57778f

Please sign in to comment.