Add capture browser and step-at-a-time browse tool
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user