diff --git a/nav_test.go b/nav_test.go index 89ff6035..68750567 100644 --- a/nav_test.go +++ b/nav_test.go @@ -348,6 +348,7 @@ func TestLoadIframe(t *testing.T) { // iframes. Sleep(10 * time.Millisecond), // WaitVisible(`#form`, ByID), // for the nested form.html + WaitVisible(`#parent`, ByID), // for iframe.html }); err != nil { t.Fatal(err) } diff --git a/target.go b/target.go index 8320b0f9..b9cf39f8 100644 --- a/target.go +++ b/target.go @@ -205,7 +205,11 @@ func (t *Target) pageEvent(ev interface{}) { switch e := ev.(type) { case *page.EventFrameNavigated: t.frames[e.Frame.ID] = e.Frame - t.cur = e.Frame + if e.Frame.ParentID == "" { + // This frame is only the new top-level frame if it has + // no parent. + t.cur = e.Frame + } return case *page.EventFrameAttached: diff --git a/testdata/iframe.html b/testdata/iframe.html index 72a59e06..37e74046 100644 --- a/testdata/iframe.html +++ b/testdata/iframe.html @@ -4,6 +4,7 @@ page with an iframe +