diff --git a/page.go b/page.go index 0c0de203..f459bb3f 100644 --- a/page.go +++ b/page.go @@ -653,7 +653,12 @@ func (p *Page) getExecutionID(force bool) (proto.RuntimeExecutionContextID, erro if !force { if ctxID, has := p.executionIDs[frameID]; has { - return ctxID, nil + _, err := proto.RuntimeEvaluate{ContextID: ctxID, Expression: `0`}.Call(p) + if err == nil { + return ctxID, nil + } else if !isNilContextErr(err) { + return 0, err + } } } diff --git a/query_test.go b/query_test.go index 971f1f28..ed486209 100644 --- a/query_test.go +++ b/query_test.go @@ -65,6 +65,15 @@ func (s *S) TestSearchIframes() { s.True(el.Click().Matches("[a=ok]")) } +func (s *S) TestSearchIframesAfterReload() { + p := s.page.Navigate(srcFile("fixtures/click-iframes.html")) + frame := p.Element("iframe").Frame().Element("iframe").Frame() + frame.Eval(`location.reload()`) + el := p.Search("button[onclick]") + s.Equal("click me", el.Text()) + s.True(el.Click().Matches("[a=ok]")) +} + func (s *S) TestPageElementX() { s.page.Navigate(srcFile("fixtures/click.html")) s.page.Element("body")