Skip to content

Commit 9173245

Browse files
p0dejeshs96c
authored andcommitted
[rb] Use server binary target
1 parent 383602b commit 9173245

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
lines changed

java/src/org/openqa/selenium/grid/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ java_binary(
3434
"//common:linux": [
3535
"@linux_chrome//:chrome-linux64/chrome",
3636
"@linux_chromedriver//:chromedriver",
37+
"@linux_edge//:opt/microsoft/msedge/microsoft-edge",
38+
"@linux_edgedriver//:msedgedriver",
3739
"@linux_firefox//:firefox/firefox",
3840
"@linux_geckodriver//:geckodriver",
3941
],
4042
"//common:macos": [
4143
"@mac_chrome//:Chrome.app",
4244
"@mac_chromedriver//:chromedriver",
45+
"@mac_edge//:Edge.app",
46+
"@mac_edgedriver//:msedgedriver",
4347
"@mac_firefox//:Firefox.app",
4448
"@mac_geckodriver//:geckodriver",
4549
],
@@ -49,12 +53,16 @@ java_binary(
4953
"//common:linux": [
5054
"-Dwebdriver.chrome.driver=$(location @linux_chromedriver//:chromedriver)",
5155
"-Dwebdriver.chrome.binary=$(location @linux_chrome//:chrome-linux64/chrome)",
56+
"-Dwebdriver.edge.binary=$(location @linux_edge//:opt/microsoft/msedge/microsoft-edge)",
57+
"-Dwebdriver.edge.driver=$(location @linux_edgedriver//:msedgedriver)",
5258
"-Dwebdriver.gecko.driver=$(location @linux_geckodriver//:geckodriver)",
5359
"-Dwebdriver.firefox.bin=$(location @linux_firefox//:firefox/firefox)",
5460
],
5561
"//common:macos": [
5662
"-Dwebdriver.chrome.driver=$(location @mac_chromedriver//:chromedriver)",
5763
"-Dwebdriver.chrome.binary=$(location @mac_chrome//:Chrome.app)/Contents/MacOS/Chrome",
64+
"-Dwebdriver.edge.binary=\"$(location @mac_edge//:Edge.app)/Contents/MacOS/Microsoft Edge\"",
65+
"-Dwebdriver.edge.driver=$(location @mac_edgedriver//:msedgedriver)",
5866
"-Dwebdriver.gecko.driver=$(location @mac_geckodriver//:geckodriver)",
5967
"-Dwebdriver.firefox.bin=$(location @mac_firefox//:Firefox.app)/Contents/MacOS/firefox",
6068
],

rb/lib/selenium/server.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,14 @@ def stop_process
240240
def process
241241
@process ||= begin
242242
# extract any additional_args that start with -D as options
243-
properties = @additional_args.dup - @additional_args.delete_if { |arg| arg[/^-D/] }
244-
args = ['-jar', @jar, @role, '--port', @port.to_s]
245-
server_command = [@java] + properties + args + @additional_args
243+
properties = @additional_args.dup - @additional_args.delete_if { |arg| arg[/^(--jvm_flag=)?-D/] }
244+
server_command = if @jar.end_with?('.jar')
245+
[@java, *properties, '-jar', @jar]
246+
else
247+
[@jar, *properties]
248+
end
249+
args = [@role, '--port', @port.to_s]
250+
server_command += args + @additional_args
246251
cp = WebDriver::ChildProcess.build(*server_command)
247252

248253
if @log.is_a?(String)

rb/spec/BUILD.bazel

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,3 @@ rb_library(
118118
"//rb/spec/unit/selenium/webdriver/support:select",
119119
],
120120
)
121-
122-
genrule(
123-
name = "java-location",
124-
srcs = [],
125-
outs = ["java-location.txt"],
126-
cmd = "echo $(JAVA) > $@",
127-
toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
128-
visibility = ["//rb/spec:__subpackages__"],
129-
)

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,17 @@ def app_server
8989

9090
def remote_server
9191
args = if ENV.key?('CHROMEDRIVER_BINARY')
92-
["-Dwebdriver.chrome.driver=#{ENV['CHROMEDRIVER_BINARY']}"]
92+
["--jvm_flag=-Dwebdriver.chrome.driver=#{ENV['CHROMEDRIVER_BINARY']}"]
9393
elsif ENV.key?('MSEDGEDRIVER_BINARY')
94-
["-Dwebdriver.edge.driver=#{ENV['MSEDGEDRIVER_BINARY']}"]
94+
["--jvm_flag=-Dwebdriver.edge.driver=#{ENV['MSEDGEDRIVER_BINARY']}"]
9595
elsif ENV.key?('GECKODRIVER_BINARY')
96-
["-Dwebdriver.gecko.driver=#{ENV['GECKODRIVER_BINARY']}"]
96+
["--jvm_flag=-Dwebdriver.gecko.driver=#{ENV['GECKODRIVER_BINARY']}"]
9797
else
9898
%w[--selenium-manager true --enable-managed-downloads true]
9999
end
100100

101101
@remote_server ||= Selenium::Server.new(
102102
remote_server_jar,
103-
java: bazel_java,
104103
port: random_port,
105104
log_level: WebDriver.logger.debug? && 'FINE',
106105
background: true,
@@ -109,12 +108,6 @@ def remote_server
109108
)
110109
end
111110

112-
def bazel_java
113-
return unless ENV.key?('WD_BAZEL_JAVA_LOCATION')
114-
115-
File.expand_path(File.read(File.expand_path(ENV.fetch('WD_BAZEL_JAVA_LOCATION'))).chomp)
116-
end
117-
118111
def rbe?
119112
Dir.pwd.start_with?('/mnt/engflow')
120113
end
@@ -130,6 +123,8 @@ def remote_server?
130123
end
131124

132125
def remote_server_jar
126+
return ENV['WD_BAZEL_SERVER_LOCATION'] if ENV.key?('WD_BAZEL_SERVER_LOCATION')
127+
133128
jar = 'java/src/org/openqa/selenium/grid/selenium_server_deploy.jar'
134129
test_jar = Pathname.new(Dir.pwd).join(jar)
135130
built_jar = root.join("bazel-bin/#{jar}")

rb/spec/tests.bzl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,11 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
173173
args = ["rb/spec/"],
174174
data = BROWSERS[browser]["data"] + data + [
175175
"//common/src/web",
176-
"//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar",
177-
"//rb/spec:java-location",
178-
"@bazel_tools//tools/jdk:current_java_runtime",
176+
"//java/src/org/openqa/selenium/grid:selenium_server",
179177
],
180178
env = BROWSERS[browser]["env"] | {
181-
"WD_BAZEL_JAVA_LOCATION": "$(rootpath //rb/spec:java-location)",
182179
"WD_SPEC_DRIVER": "remote",
180+
"WD_BAZEL_SERVER_LOCATION": "$(rootpath //java/src/org/openqa/selenium/grid:selenium_server)",
183181
},
184182
main = "@bundle//bin:rspec",
185183
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + ["{}-remote".format(browser)],

0 commit comments

Comments
 (0)