diff --git a/lib/examples/e2e-testing/calculator_test.go b/lib/examples/e2e-testing/calculator_test.go index 70a40cc8..fc9c72aa 100644 --- a/lib/examples/e2e-testing/calculator_test.go +++ b/lib/examples/e2e-testing/calculator_test.go @@ -3,11 +3,13 @@ package main import "testing" -// test case: 1 + 2 = 3 +const appURL = "https://go-rod.github.io/calculator/" + +// test case: 1 + 2 = 3. func TestAdd(t *testing.T) { g := setup(t) - p := g.page("https://ahfarmer.github.io/calculator") + p := g.page(appURL) p.MustElementR("button", "1").MustClick() p.MustElementR("button", `^\+$`).MustClick() @@ -18,11 +20,11 @@ func TestAdd(t *testing.T) { g.Eq(p.MustElement(".component-display").MustText(), "3") } -// test case: 2 * 3 = 6 +// test case: 2 * 3 = 6. func TestMultiple(t *testing.T) { g := setup(t) - p := g.page("https://ahfarmer.github.io/calculator") + p := g.page(appURL) // use for-loop to click each button for _, regex := range []string{"2", "x", "3", "="} { diff --git a/lib/examples/e2e-testing/setup_test.go b/lib/examples/e2e-testing/setup_test.go index be8ef74c..d7debf41 100644 --- a/lib/examples/e2e-testing/setup_test.go +++ b/lib/examples/e2e-testing/setup_test.go @@ -9,14 +9,14 @@ import ( "github.com/ysmood/got" ) -// test context +// test context. type G struct { got.G browser *rod.Browser } -// setup for tests +// setup for tests. var setup = func() func(t *testing.T) G { browser := rod.New().MustConnect() @@ -27,7 +27,7 @@ var setup = func() func(t *testing.T) G { } }() -// a helper function to create an incognito page +// a helper function to create an incognito page. func (g G) page(url string) *rod.Page { page := g.browser.MustIncognito().MustPage(url) g.Cleanup(page.MustClose)