Skip to content

Commit

Permalink
simplify the Element.Wait code
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Jul 8, 2022
1 parent ead9152 commit fe0a731
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 1 addition & 12 deletions element.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,18 +574,7 @@ func (el *Element) WaitInteractable() (pt *proto.Point, err error) {

// Wait until the js returns true
func (el *Element) Wait(opts *EvalOptions) error {
return utils.Retry(el.ctx, el.sleeper(), func() (bool, error) {
res, err := el.Evaluate(opts.This(el.Object))
if err != nil {
return true, err
}

if res.Value.Bool() {
return true, nil
}

return false, nil
})
return el.page.Context(el.ctx).Sleeper(el.sleeper).Wait(opts.This(el.Object))
}

// WaitVisible until the element is visible
Expand Down
2 changes: 1 addition & 1 deletion element_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ func TestElementEqual(t *testing.T) {
g.False(el1.MustEqual(el3))
}

func TestElementMustWait(t *testing.T) {
func TestElementWait(t *testing.T) {
g := setup(t)

p := g.page.MustNavigate(g.srcFile("fixtures/describe.html"))
Expand Down

0 comments on commit fe0a731

Please sign in to comment.