bazelbuild / rules_webtesting

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

Confused about usage #25

Closed pcj closed 8 years ago

pcj commented 8 years ago

First of all this looks like a very useful project, thanks for building it. Note that if I clone rules_webtesting 8fca1d048042fb4ba6ad892d3e4dc801a7abcc7c and bazel test //... within rules_webtesting itself, all tests pass. Great.

When I try to use it with another project, I'm loading @io_bazel_rules_webtesting and invoking web_test_repositories(java = True). Per README guidance, I have more or less the following web_test_suite:

java_test(
    name = "browser_test",
    size = "small",
    srcs = [
        "MyTest.java",
    ],
    test_class = "org.pubref.k8a.MyTest",
    tags = ["manual"],
    deps = [
        "//third_party:junit4",
        "@org_seleniumhq_java//:selenium",
        "@io_bazel_rules_web//java/com/google/testing/web",
    ],
)

web_test_suite(
    name = "browser_test_suite",
    browsers = [
        "@io_bazel_rules_web//browsers:chrome-native",
        #"@io_bazel_rules_web//browsers:chrome-external",
        #"@io_bazel_rules_web//browsers:phantomjs",
    ],
    #local = 1,
    #tags = ["requires-network"],
    test = ":browser_test",
)

However, when I try to bazel test :browser_test_suite using various browsers above, it fails with similar to The repository named 'org_chromium_chromedriver' could not be resolved and referenced by '@io_bazel_rules_webtesting//browsers:chromedriver'.

Although listed in //browsers, none of those platform workspaces exist, and they aren't loaded by virtue of web_test_repositories. Basically, I can't seem to get any of the platform_http_file repository rules to load by normal means. It does not appear that platform_http_file is intended to be used by end-user as it is package-private.

However, if I convert rules_webtesting to a local_repository, change the visibility to public, and use platform_http_file to load those resources in my own WORKSPACE (mimicing yours), it works:

load("@io_bazel_rules_webtesting//web/internal:platform_http_file.bzl", "platform_http_file")

platform_http_file(
    name = "org_chromium_chromedriver",
    amd64_sha256 = "0c01b05276da98f203dc7eb4236c2ee7fe799b432734e088549bd0aadc71958e",
    amd64_url = "http://chromedriver.storage.googleapis.com/2.24/chromedriver_linux64.zip",
    macos_sha256 = "d4f6e13d88ecf20735138f16ab1545e855a42bce41bebe73667a028871777790",
    macos_url = "http://chromedriver.storage.googleapis.com/2.24/chromedriver_mac64.zip",
)

platform_http_file(
    name = "com_google_chrome",
    amd64_sha256 = "6e26d74fd814c38cd419d1ffe87b3e81ad6cfe453e27c7a672ab3c452968e71d",
    amd64_url = "https://commondatastorage.googleapis.com/chrome-unsigned/desktop-5c0tCh/53.0.2785.116/precise64/chrome-precise64.zip",
    macos_sha256 = "84b3cf4f7a9f85fa90dda837b1e38820c83c383fcb6346bbec6448d5128dd7f9",
    macos_url = "https://commondatastorage.googleapis.com/chrome-unsigned/desktop-5c0tCh/53.0.2785.116/mac64/chrome-mac.zip",
)

platform_http_file(
    name = "org_phantomjs",
    amd64_sha256 = "86dd9a4bf4aee45f1a84c9f61cf1947c1d6dce9b9e8d2a907105da7852460d2f",
    amd64_url = "http://bazel-mirror.storage.googleapis.com/bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2",
    macos_sha256 = "538cf488219ab27e309eafc629e2bcee9976990fe90b1ec334f541779150f8c1",
    macos_url = "http://bazel-mirror.storage.googleapis.com/bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip",
)

What am I doing wrong? How are the browsers supposed to get loaded?

DrMarcII commented 8 years ago

I have made some minor changes and updated README.md and created a new release (0.0.4). Take a look and see if this helps.

pcj commented 8 years ago

Yes, that helps. Based on the new comments in the README, it would also be helpful to provide guidance on creating one's own browser definitions.

DrMarcII commented 8 years ago

Yeah, I plan to greatly expand the documentation, but I have been focused on just getting things to work consistently.

For now, you can look at the browser definitions //browser/... as examples.