func TestSpec(t *testing.T) { Convey("UserRegister", t, func() { var agoutiDriver *agouti.WebDriver var page *agouti.Page session, _ := mgo.Dial("localhost") session.DB("TESTGoNuts").DropDatabase() agoutiDriver = agouti.PhantomJS() So(agoutiDriver.Start(), ShouldBeNil) log.Println("Starting") go StartMyApp(3232, "TESTGoNuts") var err error page, err = agoutiDriver.NewPage(agouti.Browser("chrome")) So(err, ShouldBeNil) Convey("User Registration page", func() { Convey("when the user registration is reached", func() { Convey("should see the page", func() { So(page.Navigate("http://localhost:3232"), ShouldBeNil) url, _ := page.URL() So(url, ShouldEqual, "http://localhost:3232/") }) }) }) Reset(func() { So(page.Destroy(), ShouldBeNil) So(agoutiDriver.Stop(), ShouldBeNil) }) }) }
package integration_test import ( "os" "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sclevine/agouti" ) var ( phantomDriver = agouti.PhantomJS() chromeDriver = agouti.ChromeDriver() seleniumDriver = agouti.Selenium(agouti.Browser("firefox")) selendroidDriver = agouti.Selendroid("selendroid-standalone-0.15.0-with-dependencies.jar") headlessOnly = os.Getenv("HEADLESS_ONLY") == "true" mobile = os.Getenv("MOBILE") == "true" ) func TestIntegration(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Integration Suite") } var _ = BeforeSuite(func() { Expect(phantomDriver.Start()).To(Succeed()) if !headlessOnly { Expect(chromeDriver.Start()).To(Succeed()) Expect(seleniumDriver.Start()).To(Succeed())
import ( "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sclevine/agouti" . "github.com/sclevine/agouti/matchers" ) var _ = Describe("UserLogin", func() { var page *agouti.Page salutations := "Good morning at " + time.Now().String() BeforeEach(func() { var err error page, err = agoutiDriver.NewPage(agouti.Browser("firefox")) Expect(err).NotTo(HaveOccurred()) page.SetImplicitWait(10000) }) AfterEach(func() { Expect(page.Destroy()).To(Succeed()) }) It("should be able to add an entry", func() { By("redirecting the user to the page", func() { Expect(page.Navigate("http://localhost:8083/")).To(Succeed()) Expect(page).To(HaveURL("http://localhost:8083/")) }) By("loading the page completely", func() {