bazelbuild / rules_webtesting

Bazel rules to allow testing against a browser with WebDriver.
Apache License 2.0
97 stars 56 forks source link

Allow custom browser configuration #305

Closed devversion closed 6 years ago

devversion commented 6 years ago

Hey, I realize that there is no official documentation (yet). Though, we want to overwrite the chromium browser by specifying another launch argument.

I've tried creating my own target that uses the browser rule. Unfortunately I cannot just refer to /third_party/chromium because those are marked as internal.

It feels a bit odd if people would need to bring in the whole browser archive on their own, if they just want to overwrite a browser metadata/configuration.

Would it be possible to expose the third_party browser archives? or better, is there any official & better solution?

DrMarcII commented 6 years ago

In general I do expect users to bring in the third_party browser archives on their own.

That said, if you just want to add an additional argument to an existing browser configuration, you can do this with the custom_browser rule:

  1. create a metadata size.json file with the following contents: { "capabilities": {"goog:chromeOptions": {"args": ["--window-size=1024,768"]}}}

  2. Create a custom_browser rule in the BUILD file: custom_browser( name = "my-size-chromium-native", browser = "@io_bazel_rules_webtesting//browsers:chromium-native", metadata = "size.json", }

devversion commented 6 years ago

Thanks for the quick response! - That would be actually a nice solution. Where is the custom_browser rule defined? It sounds like this rule should be present somewhere?

this was my initial approach

browser(
  name = "chromium-browser",
  # Extended metadata from the webtesting rules. Since our tests most of the time try
  # to measure element boundaries, we need an explicit browser screen resolution.
  # https://github.com/bazelbuild/rules_webtesting/blob/master/browsers/BUILD.bazel#L44
  metadata = "chromium-config.json",
  deps = [
     # No access to @io_bazel_rules_webtesting//third_party
  ]
)
DrMarcII commented 6 years ago

Oops, I haven't added custom_browser to the open source project yet. However, using the metadata file I suggested and putting @io_bazel_rules_webtesting//browsers:chromium-native in the deps of a browser rule should work.

devversion commented 6 years ago

I guess that works. Thanks for the help! Very appreciated