From 2b925df0fb4bf0d1b8d0f3137b5e855604d9b8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 21 Mar 2019 20:09:46 +0000 Subject: [PATCH] rewrite TestReload without a sleep --- nav_test.go | 30 +++++++++++++++++++++++------- query_test.go | 2 -- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/nav_test.go b/nav_test.go index ad37722..3168919 100644 --- a/nav_test.go +++ b/nav_test.go @@ -2,11 +2,13 @@ package chromedp import ( "bytes" + "fmt" "image" _ "image/png" + "net/http" + "net/http/httptest" "strings" "testing" - "time" "github.com/chromedp/cdproto/emulation" "github.com/chromedp/cdproto/page" @@ -188,19 +190,33 @@ func TestStop(t *testing.T) { func TestReload(t *testing.T) { t.Parallel() - ctx, cancel := testAllocate(t, "form.html") + count := 0 + // create test server + mux := http.NewServeMux() + mux.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) { + fmt.Fprintf(res, ` + + Title + + +
+