How to drive web browser in Golang using Agouti

Driving web browser in Go

This article is about driving web browser in Golang.


Agouti is an acceptance and testing framework. It could be used together with Ginkgo which is a BDD testing framework and Gomega matcher/assertion library if you are looking for a complete testing solution for your Go project.

The following example only make use of Agouti to drive a browser.

Create the project inside $GOPATH

Create the main.go under $GOPATH/src/


Agouti supports web drivers such as PhantomJS, Selenium and Chrome.

Download the Go dependency

[ykyuen@camus driving-web-browser-in-go-example]$ dep init
Using ^2.0.0 as constraint for direct dep
Locking in v2.0 (b920a9c) for direct dep

At the moment when I am writing this article. The default downloaded version of Agouti by dep is too old. Let’s update it to the latest master manually.


Then run dep ensure to update the Agouti version.

Run the code

[ykyuen@camus driving-web-browser-in-go-example]$ go run main.go
2018/01/21 19:02:42 Getting Agouti

If you are using ChromeDriver, you should be able to see the Chrome browser will be started automatically and execute the tasks as stated in main.go.

Running in headless browser

We could also run the code in headless browsers like PhantomJS. Chrome also supports headless mode. Let’s update the code as follow.


We could still get the title from the Agouti website without starting the Chrome window.


— Originally posted on Boatswain Blog.

Like what you read? Give Ying Kit Yuen a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.