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
Merged
Prev Previous commit
Next Next commit
refactor(headless): ActionWaitLoad waits for `proto.PageLifecycleEv…
…entNameLoad`

also rename `Page.WaitLoad` to `Page.WaitStable` method.

Signed-off-by: Dwi Siswanto <git@dw1.io>
  • Loading branch information
dwisiswant0 committed Sep 13, 2024

Verified

This commit was signed with the committer’s verified signature.
GoldsteinE Max “Goldstein” Siling
commit 6ac42dd33103d913bba5bfcbca062753d4ff450d
2 changes: 1 addition & 1 deletion pkg/protocols/headless/engine/action_types.go
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ const (
// ActionWaitIdle waits for the network is completely idle (no ongoing network requests).
// name:waitidle
ActionWaitIdle
// ActionWaitLoad waits for the page to stop loading.
// ActionWaitLoad waits for the page and all its resources (like stylesheets and images) have finished loading.
// name:waitload
ActionWaitLoad
// ActionGetResource performs a get resource action on an element
9 changes: 5 additions & 4 deletions pkg/protocols/headless/engine/page_actions.go
Original file line number Diff line number Diff line change
@@ -107,7 +107,8 @@ func (p *Page) ExecuteActions(input *contextargs.Context, actions []*Action, var
event := proto.PageLifecycleEventNameNetworkIdle
err = p.WaitPageLifecycleEvent(act, outData, event)
case ActionWaitLoad:
err = p.WaitLoad(act, outData)
event := proto.PageLifecycleEventNameLoad
err = p.WaitPageLifecycleEvent(act, outData, event)
case ActionGetResource:
err = p.GetResource(act, outData)
case ActionExtract:
@@ -553,9 +554,9 @@ func (p *Page) WaitPageLifecycleEvent(act *Action, out ActionData, event proto.P
return nil
}

// WaitLoad waits for the page to load
func (p *Page) WaitLoad(act *Action, out ActionData) error {
return p.page.WaitStable(1)
// WaitStable waits until the page is stable
func (p *Page) WaitStable(act *Action, out ActionData) error {
return p.page.WaitStable(1) // 1ns
}

// GetResource gets a resource from an element from page.