Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Add TestWaitForFrameNavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Jul 22, 2022
1 parent 1a8d2c4 commit 39fbbf0
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/frame_manager_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tests

import (
"fmt"
"net/http"
"os"
"testing"
"time"
Expand Down Expand Up @@ -67,3 +69,45 @@ func TestWaitForFrameNavigationWithinDocument(t *testing.T) {
})
}
}

func TestWaitForFrameNavigation(t *testing.T) {
tb := newTestBrowser(t, withHTTPServer())
p := tb.NewPage(nil)

tb.withHandler("/first", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, `
<html>
<head>
<title>First page</title>
</head>
<body>
<a href="/second">click me</a>
</body>
</html>
`)
})
tb.withHandler("/second", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, `
<html>
<head>
<title>Second page</title>
</head>
<body>
<a href="/first">click me</a>
</body>
</html>
`)
})

require.NotNil(t, p.Goto(tb.URL("/first"), tb.toGojaValue(&common.FrameGotoOptions{
WaitUntil: common.LifecycleEventNetworkIdle,
Timeout: common.DefaultTimeout,
})))
err := tb.await(func() error {
_ = p.Click(`a`, nil)
p.WaitForNavigation(nil)
return nil
})
require.NoError(t, err)
require.Equal(t, p.Title(), "Second page")
}

0 comments on commit 39fbbf0

Please sign in to comment.