Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bazel rules to allow testing against a browser with WebDriver.

License

NotificationsYou must be signed in to change notification settings

bazelbuild/rules_webtesting

NOTE: This project is no longer being updated.

Build status

Bazel rules and supporting code to allow testing against a browser withWebDriver.

Configure your Bazel project

For each language that is used by your project, you need to add the corresponding sub module to your MODULE.bazel file:

bazel_dep(name="rules_webtesting",version="0.4.0")
bazel_dep(name="rules_webtesting_${language}",version="0.4.0")

For example for Java:

bazel_dep(name="rules_webtesting_java",version="0.4.0")

Write your tests

Write your test in the language of your choice, but use our provided Browser APIto get an instance of WebDriver.

Example Java Test

importcom.google.testing.web.WebTest;importorg.junit.Test;importorg.junit.runner.RunWith;importorg.junit.runners.JUnit4;importorg.openqa.selenium.WebDriver;@RunWith(JUnit4.class)publicclassBrowserTest {privateWebDriverdriver;@BeforepublicvoidcreateDriver() {driver =newWebTest().newWebDriverSession();  }@AfterpublicvoidquitDriver() {try {driver.quit();     }finally {driver =null;     }   }// your tests here}

Example Python Test

importunittestfromtesting.webimportwebtestclassBrowserTest(unittest.TestCase):defsetUp(self):self.driver=webtest.new_webdriver_session()deftearDown(self):try:self.driver.quit()finally:self.driver=None# Your tests hereif__name__=="__main__":unittest.main()

Example Go Test

import ("testing""github.com/tebeka/selenium""github.com/bazelbuild/rules_web_testing_go/webtest")funcTestWebApp(t*testing.T) {wd,err:=webtest.NewWebDriverSession(selenium.Capabilities{})iferr!=nil {t.Fatal(err)    }// your test hereiferr:=wd.Quit();err!=nil {t.Logf("Error quitting webdriver: %v",err)    }}

BUILD file

In your BUILD files, load the correct language specific build rule and create atest target using it:

load("@rules_web_testing_python//web:py.bzl","py_web_test_suite")py_web_test_suite(name="browser_test",srcs= ["browser_test.py"],browsers= ["@rules_webtesting//browsers:chromium-local",    ],local=True,deps= ["@rules_webtesting//testing/web"],)

[8]ページ先頭

©2009-2025 Movatter.jp