Add capture browser and step-at-a-time browse tool

This commit is contained in:
Ian Gulliver
2026-08-15 13:29:23 -07:00
parent 20c89a61d9
commit 5d6e59122a
4 changed files with 256 additions and 1 deletions
+8 -1
View File
@@ -16,8 +16,15 @@ func main() {
url := flag.String("url", "http://localhost:8080/directory/", "page to capture")
out := flag.String("out", "screenshots/capture.png", "output png path")
wait := flag.String("wait", "body", "css selector that must be visible before capturing")
remote := flag.Bool("remote", false, "attach to the capture browser on localhost:9222 instead of launching headless chrome")
flag.Parse()
ctx, cancelBrowser := chromedp.NewContext(context.Background())
ctx := context.Background()
if *remote {
var cancelAllocator context.CancelFunc
ctx, cancelAllocator = chromedp.NewRemoteAllocator(ctx, "http://localhost:9222")
defer cancelAllocator()
}
ctx, cancelBrowser := chromedp.NewContext(ctx)
defer cancelBrowser()
ctx, cancelTimeout := context.WithTimeout(ctx, 30*time.Second)
defer cancelTimeout()