Skip to content

Commit

Permalink
make sure execution context exists after frame reloading
Browse files Browse the repository at this point in the history
fix #164
  • Loading branch information
ysmood committed Jul 28, 2020
1 parent f1b8f0d commit e15678c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion page.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e15678c

Please sign in to comment.