Skip to content

Commit

Permalink
make WaitStable more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Sep 26, 2020
1 parent 4cb1a8a commit d5705aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
17 changes: 10 additions & 7 deletions element_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,18 @@ func (s *S) TestWaitInvisible() {
func (s *S) TestWaitStable() {
p := s.page.MustNavigate(srcFile("fixtures/wait-stable.html"))
el := p.MustElement("button")
el.MustWaitStable()
el.MustClick()
p.MustHas("[event=click]")
start := time.Now()
el.MustWaitStable().MustClick()
s.Greater(time.Since(start), time.Second)

ctx, cancel := context.WithCancel(context.Background())
go func() {
utils.Sleep(0.2)
cancel()
}()
s.mc.stub(1, proto.DOMGetContentQuads{}, func(send func() ([]byte, error)) ([]byte, error) {
go func() {
utils.Sleep(0.1)
cancel()
}()
return send()
})
s.Error(el.Context(ctx).WaitStable(time.Minute))

s.Panics(func() {
Expand Down
6 changes: 3 additions & 3 deletions fixtures/wait-stable.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<html>
<style>
button {
animation: move 300ms forwards;
animation: move 1s forwards;
}

@keyframes move {
from {
margin: 0;
}
to {
margin: 500px 0 0 500px;
margin: 1000px 0 0 1000px;
}
}
</style>
<body>
<button>click me</button>
<button onclick='this.setAttribute("a", "ok")'>click</button>
</body>
</html>
2 changes: 1 addition & 1 deletion must.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ func (el *Element) MustWaitLoad() *Element {

// MustWaitStable is similar to WaitStable
func (el *Element) MustWaitStable() *Element {
utils.E(el.WaitStable(100 * time.Millisecond))
utils.E(el.WaitStable(300 * time.Millisecond))
return el
}

Expand Down

0 comments on commit d5705aa

Please sign in to comment.