A Go port of SeleniumBase — simple, powerful browser automation built on playwright-go.
go get github.com/kyungw00k/seleniumbase-goPlaywright browser binaries are auto-installed on first run. Or install manually:
go run github.com/playwright-community/playwright-go/cmd/playwright@v0.5700.1 install --with-depspackage main
import (
"fmt"
"log"
"github.com/kyungw00k/seleniumbase-go/sb"
)
func main() {
err := sb.Run(func(p *sb.Page) error {
p.Open("https://example.com")
title, err := p.GetTitle()
if err != nil {
return err
}
fmt.Println("Page title:", title)
p.AssertTitle("Example Domain")
p.AssertElement("h1")
p.AssertText("Example Domain", "h1")
return nil
}, sb.WithBrowser("chromium"), sb.WithHeadless(true))
if err != nil {
log.Fatal(err)
}
}See also: sb.RunTest for testing.T integration, sb.NewPage for manual lifecycle control.
seleniumbase-go provides three ways to use the browser:
| Pattern | Use Case | Lifecycle |
|---|---|---|
sb.Run(func(p *sb.Page) error { ... }) |
Scripts & automation | Automatic |
sb.RunTest(t, func(p *sb.Page) { ... }) |
Go tests with testing.T |
Automatic, failures go to t.Fatal |
sb.NewPage(opts...) → page, cleanup, err |
Full control | Manual via defer cleanup() |
- SeleniumBase-compatible API — familiar method names from the Python library
- Selector translation — use
id=,name=,link=,css=,xpath=prefixes or bare CSS (details) - Auto-waiting assertions — Playwright's retry engine for reliable tests
- 90+ Page methods — navigation, interaction, assertions, queries, cookies, storage, JS eval, scroll, network, and more (full API)
- 25+ configuration options — browser, headless, proxy, viewport, timeout, locale, and more (all options)
- CDP stealth mode — launch Chrome with anti-detection flags (guide)
- Recorder — capture browser interactions and generate Go test code (guide)
- Visual testing — pixel-level screenshot comparison (guide)
- Parallel test runner — concurrent execution with isolated browsers (guide)
- Report generation — JUnit XML and styled HTML reports (guide)
- Remote browser — connect to BrowserStack, LambdaTest via CDP or WebSocket (guide)
- MasterQA — hybrid automated/manual verification (guide)
- Auto browser detection — finds system Chrome or installs Playwright Chromium (guide)
- Network interception — route, abort, and mock API responses
- Highlight / demo mode — visual element highlighting for debugging
- Deferred assertions — queue failures and process together
- MFA / TOTP support — generate and enter time-based one-time passwords
- Cookie persistence — save and load browser state
- Tab management, frames, dialogs — full browser control
- Escape hatches — drop down to
playwright.Page,playwright.Locator,playwright.BrowserContextanytime
| Document | Description |
|---|---|
| API Reference | All 90+ Page methods with signatures |
| Configuration | 25+ options and timeout constants |
| Selector Syntax | SeleniumBase selector translation rules |
| Feature Guide | Detailed guides for stealth, recorder, visual testing, and more |
| Example | Description |
|---|---|
examples/simple/main.go |
sb.Run — title and assertion checks |
examples/basic_test.go |
sb.RunTest — login/cart/logout flow |
examples/demo_site_test.go |
Demo mode with highlighting |
examples/visual_test.go |
Visual regression testing |
examples/stealth_coupang_test.go |
CDP stealth mode |
Run integration tests:
go test -tags integration ./examples/...SeleniumBase Python supports method name translations for 10 languages via static subclassing (e.g., self.클릭() in Korean). This is not supported in the Go port — Go method names are resolved at compile time, making runtime or alias-based translation impractical.
This project is inspired by SeleniumBase, the comprehensive Python browser automation framework. seleniumbase-go brings the same simple, powerful API design to the Go ecosystem using playwright-go as the underlying engine.
MIT. See LICENSE.