3d3bf22ccc
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.
32 lines
497 B
Go
32 lines
497 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/chromedp/chromedp"
|
|
)
|
|
|
|
func main() {
|
|
// first tab
|
|
ctx1, cancel := chromedp.NewContext(context.Background())
|
|
defer cancel()
|
|
|
|
// create new tab
|
|
ctx2, _ := chromedp.NewContext(ctx1)
|
|
|
|
// runs in first tab
|
|
if err := chromedp.Run(ctx1, myTask()); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// runs in second tab
|
|
if err := chromedp.Run(ctx2, myTask()); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func myTask() chromedp.Tasks {
|
|
return []chromedp.Action{}
|
|
}
|