120628a01c
This fixes the data race uncovered by the recent refactor to run all tests as tabs under the same browser. The problem was that a write on the pages map could be done from the goroutine calling NewContext to create a new map, while other goroutines could similarly read or write the same map. Instead of adding a lock around the map, make one of the Browser's goroutines be the sole user of the map. To make that extra obvious and avoid potential races in the future, declare the map inside the goroutine's scope. For some reason, this makes the Attributes tests flakier than before. For now, add short sleeps; we can investigate that separately, now that the data races are gone. |
||
---|---|---|
.github | ||
kb | ||
testdata | ||
.gitignore | ||
.travis.yml | ||
actions.go | ||
allocate_test.go | ||
allocate.go | ||
browser.go | ||
chromedp_test.go | ||
conn.go | ||
context.go | ||
errors.go | ||
eval.go | ||
example_test.go | ||
go.mod | ||
go.sum | ||
handler.go | ||
input_test.go | ||
input.go | ||
js.go | ||
LICENSE | ||
nav_test.go | ||
nav.go | ||
query_test.go | ||
query.go | ||
README.md | ||
sel_test.go | ||
sel.go | ||
util.go |
About chromedp
Package chromedp is a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go using the without external dependencies (ie, Selenium, PhantomJS, etc).
Installing
Install in the usual Go way:
go get -u github.com/chromedp/chromedp
Examples
Please see the examples project for more examples. Please refer to the GoDoc API listing for a summary of the API and Actions.
Resources
- chromedp: A New Way to Drive the Web - GopherCon SG 2017 talk
- Chrome DevTools Protocol - Chrome DevTools Protocol Domain documentation
- chromedp examples - various
chromedp
examples github.com/chromedp/cdproto
- GoDoc listing for the CDP domains used bychromedp
github.com/chromedp/cdproto-gen
- tool used to generatecdproto
github.com/chromedp/chromedp-proxy
- a simple CDP proxy for logging CDP clients and browsers
TODO
- Move timeouts to context (defaults)
- Implement more query selector options (allow over riding context timeouts)
- Contextual actions for "dry run" (or via an accumulator?)
- Network loader / manager
- Profiler