Package chromedp is a faster, simpler way to drive browsers (Chrome, Edge, Safari, Android, etc) without external dependencies (ie, Selenium, PhantomJS, etc).

About chromedp

Package chromedp is a faster, simpler way to drive browsers in Go using the Chrome Debugging Protocol (for Chrome, Edge, Safari, etc) without external dependencies (ie, Selenium, PhantomJS, etc).

NOTE: chromedp's API is currently unstable, and may change at a moments notice. There are likely extremely bad bugs lurking in this code. CAVEAT USER.


Install in the usual way:

go get -u


Below is a simple Google search performed using chromedp (taken from examples/simple):

This example shows logic for a simple search for a known website, clicking on the right link, and then taking a screenshot of a specific element on the loaded page and saving that to a local file on disk.

package main

import (

    cdp ""
    cdptypes ""

func main() {
    var err error

    // create context
    ctxt, cancel := context.WithCancel(context.Background())
    defer cancel()

    // create chrome instance
    c, err := cdp.New(ctxt)
    if err != nil {

    // run task list
    var site, res string
    err = c.Run(ctxt, googleSearch("", "Easy Money Management", &site, &res))
    if err != nil {

    // shutdown chrome
    err = c.Shutdown(ctxt)
    if err != nil {

    // wait for chrome to finish
    err = c.Wait()
    if err != nil {

    log.Printf("saved screenshot of #testimonials from search result listing `%s` (%s)", res, site)

func googleSearch(q, text string, site, res *string) cdp.Tasks {
    var buf []byte
    sel := fmt.Sprintf(`//a[text()[contains(., '%s')]]`, text)
    return cdp.Tasks{
        cdp.Sleep(2 * time.Second),
        cdp.WaitVisible(`#hplogo`, cdp.ByID),
        cdp.SendKeys(`#lst-ib`, q, cdp.ByID),
        cdp.Click(`input[name="btnK"]`, cdp.ByQuery),
        cdp.WaitNotVisible(`input[name="btnI"]`, cdp.ByQuery),
        cdp.Text(sel, res),
        cdp.Sleep(2 * time.Second),
        cdp.WaitVisible(`#footer`, cdp.ByQuery),
        cdp.WaitNotVisible(`div.v-middle >`, cdp.ByQuery),
        cdp.Screenshot(`#testimonials`, &buf, cdp.ByID),
        cdp.ActionFunc(func(context.Context, cdptypes.FrameHandler) error {
            return ioutil.WriteFile("testimonials.png", buf, 0644)

Please see the examples directory for examples.


  • 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
  • More examples
  • Profiler
  • Unit tests / coverage: travis-ci + coveralls integration

Related Repositories



Chrome Debugging Protocol Proxy - reverse websocket proxy suitable for debugging ...