bazelbuild / rules_webtesting

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

Add Selenium Support package to java_repositories() #447

Closed ptmphuong closed 1 year ago

ptmphuong commented 1 year ago

This package is needed when a user wants to use the Java WebTest API with Selenium Wait to interact with G_testrunner.

Usage example:

import com.google.testing.web.WebTest;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.FluentWait;

public class TestDriver {
  private WebDriver driver;
  private String testURL;

  public WebtestDriver(String testURL) {
    this.driver = new WebTest().newWebDriverSession();
    this.testURL = testURL;
  }

  public void run() {
    driver.get(this.testURL);

    new FluentWait<>((JavascriptExecutor) driver)
        .pollingEvery(Duration.ofMillis(POLL_INTERVAL))
        .withTimeout(Duration.ofSeconds(TEST_TIMEOUT))
        .until(executor ->
                (boolean) executor.executeScript("return window.top.G_testRunner.isFinished()")));
  }
}
google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

gkdn commented 1 year ago

@mtrea I'm not sure what is the prefer process. Would you prefer this PR or a CL for this?

mtrea commented 1 year ago

GitHub is our preferred source-of-truth, so this is correct, thanks!

mtrea commented 1 year ago

You can upstream this internally, just go ahead and cite this pull request in the CL description.