@@ -38,6 +38,7 @@ BROWSERS = {
3838 "deps" : ["//rb/lib/selenium/webdriver:chrome" ],
3939 "tags" : [],
4040 "target_compatible_with" : [],
41+ "bidi" : True ,
4142 "env" : {
4243 "WD_REMOTE_BROWSER" : "chrome" ,
4344 "WD_SPEC_DRIVER" : "chrome" ,
@@ -62,6 +63,7 @@ BROWSERS = {
6263 "deps" : ["//rb/lib/selenium/webdriver:edge" ],
6364 "tags" : [],
6465 "target_compatible_with" : [],
66+ "bidi" : True ,
6567 "env" : {
6668 "WD_REMOTE_BROWSER" : "edge" ,
6769 "WD_SPEC_DRIVER" : "edge" ,
@@ -108,6 +110,7 @@ BROWSERS = {
108110 "deps" : ["//rb/lib/selenium/webdriver:firefox" ],
109111 "tags" : [],
110112 "target_compatible_with" : [],
113+ "bidi" : True ,
111114 "env" : {
112115 "WD_REMOTE_BROWSER" : "firefox" ,
113116 "WD_SPEC_DRIVER" : "firefox" ,
@@ -165,7 +168,25 @@ BROWSERS = {
165168
166169DEFAULT_BROWSERS = [b for b in BROWSERS .keys () if b not in ("ie" , "safari-preview" )]
167170
168- def rb_integration_test (name , srcs , deps = [], data = [], browsers = DEFAULT_BROWSERS , tags = []):
171+ # Tags listed here apply only to the local target of the listed browsers.
172+ _BROWSER_TAG_FILTERS = {
173+ "os-sensitive" : ["chrome-beta" , "edge" , "firefox-beta" , "safari" ],
174+ }
175+
176+ def _split_filtered_tags (tags , browser ):
177+ universal_tags = [t for t in tags if t not in _BROWSER_TAG_FILTERS ]
178+ local_tags = [t for t in tags if browser in _BROWSER_TAG_FILTERS .get (t , [])]
179+ return universal_tags , local_tags
180+
181+ def rb_integration_test (
182+ name ,
183+ srcs ,
184+ deps = [],
185+ data = [],
186+ browsers = DEFAULT_BROWSERS ,
187+ tags = [],
188+ bidi_only = False ,
189+ no_grid = False ):
169190 # Generate a library target that is used by //rb/spec:spec to expose all tests to //rb:lint.
170191 rb_library (
171192 name = name ,
@@ -174,46 +195,49 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = DEFAULT_BRO
174195 )
175196
176197 for browser in browsers :
177- # Generate a test target for local browser execution.
178- rb_test (
179- name = "{}-{}" .format (name , browser ),
180- size = "large" ,
181- srcs = srcs ,
182- args = ["rb/spec/" ],
183- data = BROWSERS [browser ]["data" ] + data + ["//common/src/web" ],
184- env = BROWSERS [browser ]["env" ],
185- main = "@bundle//bin:rspec" ,
186- tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + tags + [browser ],
187- deps = ["//rb/spec/integration/selenium/webdriver:spec_helper" ] + BROWSERS [browser ]["deps" ] + deps ,
188- visibility = ["//rb:__subpackages__" ],
189- target_compatible_with = BROWSERS [browser ]["target_compatible_with" ],
190- )
198+ universal_tags , local_tags = _split_filtered_tags (tags , browser )
199+ if not bidi_only :
200+ # Generate a test target for local browser execution.
201+ rb_test (
202+ name = "{}-{}" .format (name , browser ),
203+ size = "large" ,
204+ srcs = srcs ,
205+ args = ["rb/spec/" ],
206+ data = BROWSERS [browser ]["data" ] + data + ["//common/src/web" ],
207+ env = BROWSERS [browser ]["env" ],
208+ main = "@bundle//bin:rspec" ,
209+ tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + universal_tags + local_tags + [browser ],
210+ deps = ["//rb/spec/integration/selenium/webdriver:spec_helper" ] + BROWSERS [browser ]["deps" ] + deps ,
211+ visibility = ["//rb:__subpackages__" ],
212+ target_compatible_with = BROWSERS [browser ]["target_compatible_with" ],
213+ )
191214
192- # Generate a test target for remote browser execution (Grid).
193- rb_test (
194- name = "{}-{}-remote" .format (name , browser ),
195- size = "large" ,
196- srcs = srcs ,
197- args = ["rb/spec/" ],
198- data = BROWSERS [browser ]["data" ] + data + [
199- "//common/src/web" ,
200- "//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar" ,
201- "//rb/spec:java-location" ,
202- "@bazel_tools//tools/jdk:current_java_runtime" ,
203- ],
204- env = BROWSERS [browser ]["env" ] | {
205- "WD_BAZEL_JAVA_LOCATION" : "$(rootpath //rb/spec:java-location)" ,
206- "WD_SPEC_DRIVER" : "remote" ,
207- },
208- main = "@bundle//bin:rspec" ,
209- tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + tags + ["{}-remote" .format (browser )],
210- deps = ["//rb/spec/integration/selenium/webdriver:spec_helper" ] + BROWSERS [browser ]["deps" ] + deps ,
211- visibility = ["//rb:__subpackages__" ],
212- target_compatible_with = BROWSERS [browser ]["target_compatible_with" ],
213- )
215+ # Generate a test target for remote browser execution (Grid).
216+ if not no_grid :
217+ rb_test (
218+ name = "{}-{}-remote" .format (name , browser ),
219+ size = "large" ,
220+ srcs = srcs ,
221+ args = ["rb/spec/" ],
222+ data = BROWSERS [browser ]["data" ] + data + [
223+ "//common/src/web" ,
224+ "//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar" ,
225+ "//rb/spec:java-location" ,
226+ "@bazel_tools//tools/jdk:current_java_runtime" ,
227+ ],
228+ env = BROWSERS [browser ]["env" ] | {
229+ "WD_BAZEL_JAVA_LOCATION" : "$(rootpath //rb/spec:java-location)" ,
230+ "WD_SPEC_DRIVER" : "remote" ,
231+ },
232+ main = "@bundle//bin:rspec" ,
233+ tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + universal_tags + ["{}-remote" .format (browser )],
234+ deps = ["//rb/spec/integration/selenium/webdriver:spec_helper" ] + BROWSERS [browser ]["deps" ] + deps ,
235+ visibility = ["//rb:__subpackages__" ],
236+ target_compatible_with = BROWSERS [browser ]["target_compatible_with" ],
237+ )
214238
215- # Generate a test target for bidi browser execution if there is a matching tag
216- if "bidi" in tags :
239+ # Generate a test target for bidi browser execution on browsers that opt in.
240+ if ( "bidi" in tags or bidi_only ) and BROWSERS [ browser ]. get ( "bidi" , False ) :
217241 rb_test (
218242 name = "{}-{}-bidi" .format (name , browser ),
219243 size = "large" ,
@@ -222,7 +246,7 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = DEFAULT_BRO
222246 data = BROWSERS [browser ]["data" ] + data + ["//common/src/web" ],
223247 env = BROWSERS [browser ]["env" ] | {"WEBDRIVER_BIDI" : "true" },
224248 main = "@bundle//bin:rspec" ,
225- tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + tags + ["{}-bidi" .format (browser )],
249+ tags = COMMON_TAGS + BROWSERS [browser ]["tags" ] + universal_tags + ["{}-bidi" .format (browser )],
226250 deps = {d : True for d in (
227251 ["//rb/spec/integration/selenium/webdriver:spec_helper" , "//rb/lib/selenium/webdriver:bidi" ] +
228252 BROWSERS [browser ]["deps" ] +
@@ -241,7 +265,7 @@ def rb_unit_test(name, srcs, deps, data = [], flaky = False):
241265 flaky = flaky ,
242266 main = "@bundle//bin:rspec" ,
243267 data = data ,
244- tags = ["no-sandbox " ], # TODO: Do we need this?
268+ tags = ["unit " ],
245269 deps = ["//rb/spec/unit/selenium/webdriver:spec_helper" ] + deps ,
246270 visibility = ["//rb:__subpackages__" ],
247271 )
0 commit comments