chromedp/_example/allocactor.go
Daniel Martí 3d3bf22ccc start the chromedp v2 refactor
First, we want all of the functionality in a single package; this means
collapsing whatever is useful into the root chromedp package.

The runner package is being replaced by the Allocator interface, with a
default implementation which starts browser processes.

The client package doesn't really have a place in the new design. The
context, allocator, and browser types will handle the connection with
each browser.

Finally, the new API is context-based, hence the addition of context.go.
The tests have been modified to build and run against the new API.
2019-04-01 12:17:28 +01:00

27 lines
497 B
Go

package main
import (
"context"
"log"
"github.com/chromedp/chromedp"
)
func main() {
dockerAllocatorOpts := []chromedp.DockerAllocatorOption{}
ctxt, cancel := chromedp.NewAllocator(context.Background(), chromedp.WithDockerAllocator(dockerAllocatorOpts...))
defer cancel()
task1Context, cancel := chromedp.NewContext(ctxt)
defer cancel()
if err := chromedp.Run(task1Context, myTask()); err != nil {
log.Fatal(err)
}
}
func myTask() chromedp.Tasks {
return []chromedp.Action{}
}