All Projects → bazelbuild → Rules_webtesting

bazelbuild / Rules_webtesting

Licence: apache-2.0
Bazel rules to allow testing against a browser with WebDriver.

Programming Languages

python
139335 projects - #7 most used programming language
java
68154 projects - #9 most used programming language
go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Rules webtesting

Java.appium
Mobile test automation using Appium in Java
Stars: ✭ 59 (-15.71%)
Mutual labels:  selenium, webdriver
Selendroid
"Selenium for Android" (Test automate native or hybrid Android apps and the mobile web with Selendroid.) Join us on IRC #selendroid on freenode. Also confirm you have signed the CLA http://goo.gl/pAvxEI when making a Pull Request.
Stars: ✭ 828 (+1082.86%)
Mutual labels:  selenium, webdriver
Webdrivers
Keep your Selenium WebDrivers updated automatically
Stars: ✭ 466 (+565.71%)
Mutual labels:  selenium, webdriver
Php Webdriver
PHP client for Selenium/WebDriver protocol. Previously facebook/php-webdriver
Stars: ✭ 4,477 (+6295.71%)
Mutual labels:  selenium, webdriver
Wd
Use WebDriver from the command line
Stars: ✭ 31 (-55.71%)
Mutual labels:  selenium, webdriver
Minkselenium2driver
Selenium2 (webdriver) driver for Mink framework
Stars: ✭ 461 (+558.57%)
Mutual labels:  selenium, webdriver
Selenium Python
Selenium Python Bindings Documentation
Stars: ✭ 640 (+814.29%)
Mutual labels:  selenium, webdriver
Selenium Maven Template
A maven template for Selenium that will let you check out and go.
Stars: ✭ 403 (+475.71%)
Mutual labels:  selenium, webdriver
Marionette client
Mozilla's Gecko Marionette client in golang
Stars: ✭ 21 (-70%)
Mutual labels:  selenium, webdriver
Wdio Workshop
WebdriverIO Workshop
Stars: ✭ 20 (-71.43%)
Mutual labels:  selenium, webdriver
Python web framework
这是一个关于python的WebUI自动化测试的项目,之前用的是unittest测试框架,现在改成pytest测试框架,Python+PageObject+Pytest
Stars: ✭ 49 (-30%)
Mutual labels:  selenium, webdriver
Memedensity
CLI tool to let you know amount of memes in facebook feed.
Stars: ✭ 44 (-37.14%)
Mutual labels:  selenium, webdriver
Selenium
A browser automation framework and ecosystem.
Stars: ✭ 22,369 (+31855.71%)
Mutual labels:  selenium, webdriver
Tib
Easy e2e browser testing in Node
Stars: ✭ 64 (-8.57%)
Mutual labels:  selenium, webdriver
Golem
A complete test automation tool
Stars: ✭ 441 (+530%)
Mutual labels:  selenium, webdriver
Docker Selenium
Docker images for the Selenium Grid Server
Stars: ✭ 5,476 (+7722.86%)
Mutual labels:  selenium, webdriver
Atata
C#/.NET test automation framework for web
Stars: ✭ 362 (+417.14%)
Mutual labels:  selenium, webdriver
Undetected Chromedriver
Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
Stars: ✭ 365 (+421.43%)
Mutual labels:  selenium, webdriver
E2e Experiment
A demo project with Spring Boot / Angular application and e2e tests
Stars: ✭ 9 (-87.14%)
Mutual labels:  selenium, webdriver
Edge Selenium Tools
An updated EdgeDriver implementation for Selenium 3 with newly-added support for Microsoft Edge (Chromium).
Stars: ✭ 41 (-41.43%)
Mutual labels:  selenium, webdriver

Bazel Web Testing Rules

Build Status Build status

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

Configure your Bazel project

For all languages, you need to add the following to your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "io_bazel_rules_webtesting",
    sha256 = "<version-specific-sha>",
    urls = [
        "https://github.com/bazelbuild/rules_webtesting/releases/download/<version>/rules_webtesting.tar.gz",
    ],
)

load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")

web_test_repositories()

We maintain predefined versioned browsers in @io_bazel_rules_webtesting//web/versioned:browsers-<version>.bzl that can be referenced from @io_bazel_rules_webtesting//browsers. Note: these versions in these files are not locked in until the corresponding release has been created.

To use, add the following to your WORKSPACE file:

load("@io_bazel_rules_webtesting//web/versioned:browsers-<version>.bzl", "browser_repositories")

browser_repositories(chromium=True, firefox=True)

Then you should add the appropriate dependencies depending on what language you are writing your tests in:

Java

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

java_repositories()

Using rules_jvm_external?

If you're using rules_jvm_external to manage your dependencies, you can add the required artifacts directly to your maven_install instead of using java_repositories.

load("@io_bazel_rules_webtesting//web:java_repositories.bzl", "RULES_WEBTESTING_ARTIFACTS")

maven_install(
    artifacts = [
      # Your artifacts
    ] + RULES_WEBTESTING_ARTIFACTS,
    # Enabling compatability support is required.
    generate_compat_repositories = True,
)

Scala

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

java_repositories()

http_archive(
    name = "io_bazel_rules_scala",
    sha256 = "6c69597f373a01989b9f7119bd5d28cffc9cc35d44d1f6440c409d8ef420057d",
    strip_prefix = "rules_scala-da5ba6d97a1abdadef89d509b30a9dcfde7ffbe4",
    urls = [
        "https://github.com/bazelbuild/rules_scala/archive/da5ba6d97a1abdadef89d509b30a9dcfde7ffbe4.tar.gz",
    ],
)

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")

scala_repositories()

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")

scala_register_toolchains()

Python

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

py_repositories()

Go

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "b7a62250a3a73277ade0ce306d22f122365b513f5402222403e507f2f997d421",
    urls = [
        "https://github.com/bazelbuild/rules_go/releases/download/0.16.3/rules_go-0.16.3.tar.gz",
    ],
)

http_archive(
    name = "bazel_gazelle",
    sha256 = "6e875ab4b6bf64a38c352887760f21203ab054676d9c1b274963907e0768740d",
    urls = [
        "https://github.com/bazelbuild/bazel-gazelle/releases/download/0.15.0/bazel-gazelle-0.15.0.tar.gz",
    ],
)

load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

gazelle_dependencies()

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

go_repositories()

Write your tests

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

Example Java Test

import com.google.testing.web.WebTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openqa.selenium.WebDriver;

@RunWith(JUnit4.class)
public class BrowserTest {
  private WebDriver driver;

  @Before public void createDriver() {
    driver = new WebTest().newWebDriverSession();
  }

  @After public void quitDriver() {
    try {
      driver.quit();
     } finally {
      driver = null;
     }
   }

  // your tests here
}

Example Python Test

import unittest
from testing.web import webtest


class BrowserTest(unittest.TestCase):
  def setUp(self):
    self.driver = webtest.new_webdriver_session()

  def tearDown(self):
    try:
      self.driver.quit()
    finally:
      self.driver = None

  # Your tests here

if __name__ == "__main__":
  unittest.main()

Example Go Test

import (
    "testing"

    "github.com/tebeka/selenium"
    "github.com/bazelbuild/rules_webtesting/go/webtest"
)

func TestWebApp(t *testing.T) {
    wd, err := webtest.NewWebDriverSession(selenium.Capabilities{})
    if err != nil {
        t.Fatal(err)
    }

    // your test here

    if err := 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 a test target using it:

load("@io_bazel_rules_webtesting//web:py.bzl", "py_web_test_suite")

py_web_test_suite(
    name = "browser_test",
    srcs = ["browser_test.py"],
    browsers = [
        "@io_bazel_rules_webtesting//browsers:chromium-local",
    ],
    local = True,
    deps = ["@io_bazel_rules_webtesting//testing/web"],
)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].