Chrome DevTools Protocol client for browser automation
CLAUDE.md: update error wrapping guidance to reflect coreerr.E() convention. Console buffer trimming in both Webview.addConsoleMessage and ConsoleWatcher.addMessage panicked with slice bounds out of range when consoleLimit was smaller than 100. Use min(100, len) for safe batch trimming. Added 22 unit tests covering pure functions (FormatConsoleOutput, containsString, findString, formatJSValue, getString), ConsoleWatcher filter/count/handler logic, ExceptionWatcher operations, WaitAction context handling, and buffer limit enforcement. Coverage: 3.2% → 16.1%. DX audit findings: - Error handling: clean (all coreerr.E(), no fmt.Errorf) - File I/O: clean (no os.ReadFile/os.WriteFile — package uses HTTP/WS only) Co-Authored-By: Virgil <virgil@lethean.io> |
||
|---|---|---|
| .core | ||
| .forgejo/workflows | ||
| docs | ||
| .editorconfig | ||
| .gitignore | ||
| .golangci.yml | ||
| actions.go | ||
| angular.go | ||
| cdp.go | ||
| CLAUDE.md | ||
| console.go | ||
| CONTRIBUTING.md | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
| webview.go | ||
| webview_test.go | ||
go-webview
Chrome DevTools Protocol (CDP) client for browser automation, testing, and scraping. Connects to an externally managed Chrome or Chromium instance running with --remote-debugging-port=9222, providing navigation, DOM queries, click and type actions, console capture, JavaScript evaluation, screenshots, multi-tab support, viewport emulation, and a fluent ActionSequence builder. Includes Angular-specific helpers for Zone.js stability, router navigation, component introspection, and ngModel access.
Module: forge.lthn.ai/core/go-webview
Licence: EUPL-1.2
Language: Go 1.25
Quick Start
import "forge.lthn.ai/core/go-webview"
wv, err := webview.New(webview.WithDebugURL("http://localhost:9222"))
defer wv.Close()
wv.Navigate("https://example.com")
wv.Click("#submit")
wv.Type("#input", "search term")
png, err := wv.Screenshot()
// Fluent action sequence
err = webview.NewActionSequence().
Navigate("https://example.com").
WaitForSelector("#login-form").
Type("#email", "user@example.com").
Click("#submit").
Execute(ctx, wv)
Documentation
- Architecture — CDP connection, DOM queries, console capture, Angular helpers, action system
- Development Guide — prerequisites, build, test patterns, adding actions
- Project History — completed phases, known limitations, future considerations
Build & Test
go test ./...
go vet ./...
go build ./...
Licence
European Union Public Licence 1.2 — see LICENCE for details.