Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Fix waitForSelector by calling waitFor
Browse files Browse the repository at this point in the history
The fix is in waitFor, and waitForSelector just needs to call waitFor
to enable the fix.

It basically will auto retry up to 20 times when certain errors are
received from chrome. This can happens when the underlying DOM is
changing due to a navigation, and the expected element that matches the
selector is in the newly navigated DOM.
  • Loading branch information
ankur22 committed Nov 12, 2024
1 parent 38efd45 commit 982cab9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions common/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,16 @@ func (f *Frame) waitForSelectorRetry(
return nil, err
}

// waitForSelector will wait for the given selector to reach a defined state in
// opts.
//
// It will auto retry on certain errors until the retryCount is below 0. The
// retry workaround is needed since the underlying DOM can change when the
// wait action is performed during a navigation.
func (f *Frame) waitForSelector(selector string, opts *FrameWaitForSelectorOptions) (_ *ElementHandle, rerr error) {
f.log.Debugf("Frame:waitForSelector", "fid:%s furl:%q sel:%q", f.ID(), f.URL(), selector)

document, err := f.document()
if err != nil {
return nil, err
}

handle, err := document.waitForSelector(f.ctx, selector, opts)
handle, err := f.waitFor(selector, opts, 20)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 982cab9

Please sign in to comment.