Agouti 2.0 Released

February 20, 2015 Stephen Levine

Agouti is a WebDriver client and acceptance/integration testing framework for Go. It is designed to work seamlessly with Ginkgo and Gomega in the same way that Capybara works with RSpec in Ruby-land. Agouti is compatible with Selenium WebDriver, PhantomJS, and ChromeDriver. It also plays nicely with Ginkgo’s ability to run specs in parallel, which can speed up your integration test suite significantly!

agouti

Agouti 2.0 is more Gopher-friendly than the last release. The agouti/core package was deprecated in favor of just importing (and not dot-importing!) the agouti package. The agouti/core package will stick around for the time being, but will eventually be removed. New features include full support for switching between windows and frames, support for reading JavaScript (and other) logs, as well as support for selecting buttons by their text. The new agouti/api package permits direct communication with the WebDriver by acting as a wrapper-client for the WebDriver Wire Protocol. Agouti 2.0 also includes improved godoc and numerous bug fixes.

Read more at agouti.org and on Github. Or dive right into the GoDoc.

Here’s what the login spec from my last post looks like in Agouti 2.0:

package yourpackage_test

import (
    . "github.com/onsi/ginkgo"
    . "github.com/onsi/gomega"
    . "github.com/sclevine/agouti/matchers"
    "github.com/sclevine/agouti"
)

var _ = Describe("User Login - Agouti 2.0", func() {
    var page *agouti.Page

    BeforeEach(func() {
        var err error
        page, err = agoutiDriver.NewPage()
        Expect(err).NotTo(HaveOccurred())
    })

    AfterEach(func() {
        Expect(page.Destroy()).To(Succeed())
    })

    It("should manage user authentication", func() {
        By("redirecting the user to the login form", func() {
            Expect(page.Navigate("http://localhost:3000")).To(Succeed())
            Expect(page).To(HaveURL("http://localhost:3000/login"))
        })

        By("allowing the user to fill out the login form", func() {
            userField := page.FindByLabel("User")
            Eventually(userField.Fill("bob")).Should(Succeed())
            passwordField := page.FindByLabel("Password")
            Expect(passwordField.Fill("secret")).To(Succeed())
            Expect(page.FindByLabel("Remember Me").Check()).To(Succeed())
            Expect(page.FindByButton("Submit").Submit()).To(Succeed())
        })

        By("directing the user to the dashboard", func() {
            Eventually(page).Should(HaveTitle("Dashboard"))
        })

        By("allowing the user to open their profile window", func() {
            Expect(page.FindByLink("Profile").Click()).To(Succeed())
            Expect(page.WindowCount()).To(Equal(2))
            Expect(page.NextWindow()).To(Succeed())
            profile := page.Find("section.profile")
            Eventually(profile.Find(".greet")).Should(HaveText("Hello!"))
            Expect(profile.Find("img#profile_pic")).To(BeVisible())
            Expect(page.CloseWindow()).To(Succeed())
        })

        By("allowing the user to log out", func() {
            Expect(page.FindByButton("Logout").Click()).To(Succeed())
            Expect(page).To(HavePopupText("Are you sure?"))
            Expect(page.ConfirmPopup()).To(Succeed())
            Eventually(page).Should(HaveTitle("Login"))
        })
    })
})

About the Author

Biography

More Content by Stephen Levine
Previous
How to Define Your Value Proposition
How to Define Your Value Proposition

In 2014, Pivotal Labs hosted over 50 sessions of Product Office Hours, an hour of free advice to help entre...

Next
Open Data Platform Initiative: Putting an End to “Faux-pen” Source Apache Hadoop Distributions
Open Data Platform Initiative: Putting an End to “Faux-pen” Source Apache Hadoop Distributions

In the wake of the Open Data Platform (ODP) initiative announced earlier this week, Pivotal’s Roman Shaposh...

Enter curious. Exit smarter.

Register Now