@@ -14,6 +14,8 @@ BROWSERS = {
1414 "deps" : ["//rb/lib/selenium/webdriver:chrome" ],
1515 "tags" : [],
1616 "target_compatible_with" : [],
17+ "bidi_supported" : True ,
18+ "devtools_supported" : True ,
1719 "env" : {
1820 "WD_REMOTE_BROWSER" : "chrome" ,
1921 "WD_SPEC_DRIVER" : "chrome" ,
@@ -37,6 +39,8 @@ BROWSERS = {
3739 "deps" : ["//rb/lib/selenium/webdriver:edge" ],
3840 "tags" : [],
3941 "target_compatible_with" : [],
42+ "bidi_supported" : True ,
43+ "devtools_supported" : True ,
4044 "env" : {
4145 "WD_REMOTE_BROWSER" : "edge" ,
4246 "WD_SPEC_DRIVER" : "edge" ,
@@ -60,6 +64,7 @@ BROWSERS = {
6064 "deps" : ["//rb/lib/selenium/webdriver:firefox" ],
6165 "tags" : [],
6266 "target_compatible_with" : [],
67+ "bidi_supported" : True ,
6368 "env" : {
6469 "WD_REMOTE_BROWSER" : "firefox" ,
6570 "WD_SPEC_DRIVER" : "firefox" ,
@@ -83,6 +88,7 @@ BROWSERS = {
8388 "deps" : ["//rb/lib/selenium/webdriver:firefox" ],
8489 "tags" : [],
8590 "target_compatible_with" : [],
91+ "bidi_supported" : True ,
8692 "env" : {
8793 "WD_REMOTE_BROWSER" : "firefox" ,
8894 "WD_SPEC_DRIVER" : "firefox" ,
@@ -149,63 +155,69 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
149155 visibility = ["//rb:__subpackages__" ],
150156 )
151157
158+ VARIANTS = [
159+ {"suffix" : "" , "remote" : False , "bidi" : False },
160+ {"suffix" : "-remote" , "remote" : True , "bidi" : False },
161+ {"suffix" : "-bidi" , "remote" : False , "bidi" : True },
162+ {"suffix" : "-bidi-remote" , "remote" : True , "bidi" : True },
163+ ]
164+
152165 for browser in browsers :
153- # Generate a test target for local browser execution.
154- rb_test (
155- name = "{}-{}" .format (name , browser ),
156- size = "large" ,
157- srcs = srcs ,
158- args = ["rb/spec/" ],
159- data = BROWSERS [browser ]["data" ] + data + ["//common/src/web" ],
160- env = BROWSERS [browser ]["env" ],
161- main = "@bundle//bin:rspec" ,
162- tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + tags + [browser ],
163- deps = ["//rb/spec/integration/selenium/webdriver:spec_helper" ] + BROWSERS [browser ]["deps" ] + deps ,
164- visibility = ["//rb:__subpackages__" ],
165- target_compatible_with = BROWSERS [browser ]["target_compatible_with" ],
166- )
166+ config = BROWSERS [browser ]
167+ for variant in VARIANTS :
168+ bidi_not_supported = variant ["bidi" ] and not config .get ("bidi_supported" , False )
169+ devtools_not_supported = "needs-devtools" in tags and not config .get ("devtools_supported" , False )
170+ excluded_by_bidi = "bidi-only" in tags and not variant ["bidi" ]
171+ excluded_by_grid = "remote-only" in tags and not variant ["remote" ]
172+ excluded_by_local = "no-grid" in tags and variant ["remote" ]
167173
168- # Generate a test target for remote browser execution (Grid).
169- rb_test (
170- name = "{}-{}-remote" .format (name , browser ),
171- size = "large" ,
172- srcs = srcs ,
173- args = ["rb/spec/" ],
174- data = BROWSERS [browser ]["data" ] + data + [
175- "//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" ,
179- ],
180- env = BROWSERS [browser ]["env" ] | {
181- "WD_BAZEL_JAVA_LOCATION" : "$(rootpath //rb/spec:java-location)" ,
182- "WD_SPEC_DRIVER" : "remote" ,
183- },
184- main = "@bundle//bin:rspec" ,
185- tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + tags + ["{}-remote" .format (browser )],
186- deps = ["//rb/spec/integration/selenium/webdriver:spec_helper" ] + BROWSERS [browser ]["deps" ] + deps ,
187- visibility = ["//rb:__subpackages__" ],
188- target_compatible_with = BROWSERS [browser ]["target_compatible_with" ],
189- )
174+ if bidi_not_supported or devtools_not_supported or excluded_by_bidi or excluded_by_grid or excluded_by_local :
175+ continue
176+
177+ target_name = "{}-{}{}" .format (name , browser , variant ["suffix" ])
178+
179+ env = config ["env" ]
180+ if variant ["remote" ]:
181+ env = env | {
182+ "WD_SPEC_DRIVER" : "remote" ,
183+ "WD_BAZEL_JAVA_LOCATION" : "$(rootpath //rb/spec:java-location)" ,
184+ }
185+ if variant ["bidi" ]:
186+ env = env | {
187+ "WEBDRIVER_BIDI" : "true"
188+ }
189+
190+ test_data = config ["data" ] + data + ["//common/src/web" ]
191+ if variant ["remote" ]:
192+ test_data += [
193+ "//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar" ,
194+ "//rb/spec:java-location" ,
195+ "@bazel_tools//tools/jdk:current_java_runtime" ,
196+ ]
197+
198+ test_deps = [
199+ "//rb/spec/integration/selenium/webdriver:spec_helper"
200+ ] + config ["deps" ] + deps
201+ if variant ["bidi" ]:
202+ test_deps .append ("//rb/lib/selenium/webdriver:bidi" )
203+
204+ test_tags = COMMON_TAGS + config ["tags" ] + tags + [browser ]
205+ if variant ["bidi" ]:
206+ test_tags .append ("bidi" )
190207
191- # Generate a test target for bidi browser execution.
192- rb_test (
193- name = "{}-{}-bidi" .format (name , browser ),
194- size = "large" ,
195- srcs = srcs ,
196- args = ["rb/spec/" ],
197- data = BROWSERS [browser ]["data" ] + data + ["//common/src/web" ],
198- env = BROWSERS [browser ]["env" ] | {"WEBDRIVER_BIDI" : "true" },
199- main = "@bundle//bin:rspec" ,
200- tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + tags + ["{}-bidi" .format (browser )],
201- deps = depset (
202- ["//rb/spec/integration/selenium/webdriver:spec_helper" , "//rb/lib/selenium/webdriver:bidi" ] +
203- BROWSERS [browser ]["deps" ] +
204- deps ,
205- ),
206- visibility = ["//rb:__subpackages__" ],
207- target_compatible_with = BROWSERS [browser ]["target_compatible_with" ],
208- )
208+ rb_test (
209+ name = target_name ,
210+ size = "large" ,
211+ srcs = srcs ,
212+ args = ["rb/spec/integration" ],
213+ data = test_data ,
214+ env = env ,
215+ main = "@bundle//bin:rspec" ,
216+ tags = test_tags ,
217+ deps = depset (test_deps ),
218+ visibility = ["//rb:__subpackages__" ],
219+ target_compatible_with = config ["target_compatible_with" ],
220+ )
209221
210222def rb_unit_test (name , srcs , deps , data = []):
211223 rb_test (
0 commit comments