Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(headless): supporting standard lifecycle events #5632

Merged
merged 12 commits into from
Sep 19, 2024
Prev Previous commit
Next Next commit
feat(headless): add getNavigationFunc
Signed-off-by: Dwi Siswanto <git@dw1.io>
  • Loading branch information
dwisiswant0 committed Sep 13, 2024
commit 499806fd32cee11b3caad3f0141f51f54bd5098b
11 changes: 11 additions & 0 deletions pkg/protocols/headless/engine/page_actions.go
Original file line number Diff line number Diff line change
@@ -204,6 +204,17 @@ func createBackOffSleeper(pollTimeout, timeout time.Duration) utils.Sleeper {
}
}

func getNavigationFunc(p *Page, act *Action, event proto.PageLifecycleEventName) (func(), error) {
dur, err := getTimeout(p, act)
if err != nil {
return nil, errors.Wrap(err, "Wrong timeout given")
}

fn := p.page.Timeout(dur).WaitNavigation(event)

return fn, nil
}

func getTimeout(p *Page, act *Action) (time.Duration, error) {
return geTimeParameter(p, act, "timeout", 3, time.Second)
}