Features

Chromedp


chromedp is a golang package which allows you to automate a Chrome browser with Golang using Puppeteer syntax.

To find out more about this package, please see the chromedp documentation.

Installation


Installing chromedp is very easy:

go get -u github.com/chromedp/chromedp

Your first Test


To get started, please see this simple example:

package main

import (
  "context"
  "flag"
  "github.com/chromedp/chromedp"
  "log"
)

func main() {
  var devToolWsUrl string
  var title string

  flag.StringVar(&devToolWsUrl, "devtools-ws-url", "wss://cloud.testingbot.com?key=api_key&secret=api_secret&browserName=chrome&browserVersion=latest", "DevTools Websocket URL")
  flag.Parse()

  actxt, cancelActxt := chromedp.NewRemoteAllocator(context.Background(), devToolWsUrl)
  defer cancelActxt()

  ctxt, cancelCtxt := chromedp.NewContext(actxt) // create new tab
  defer cancelCtxt()                             // close tab afterwards

  if err := chromedp.Run(ctxt,
    chromedp.Navigate("https://testingbot.com"),
    chromedp.Title(&title),
  ); err != nil {
    log.Fatalf("Failed getting title of testingbot.com: %v", err)
  }

  log.Println("Got title of:", title)
}

This will connect with a Chrome browser running in the TestingBot cloud, go to the TestingBot homepage and print its title.

Specifying browser and version

To specify on which browser and version your Chromedp test should run, you can include both a browserName and browserVersion in the browserWSEndpoint URL.

Select a browser & version