chrome-remote-interface icon indicating copy to clipboard operation
chrome-remote-interface copied to clipboard

Page.lifecycleEvent

Open nathanjohnson320 opened this issue 5 years ago • 1 comments

Hi all, great library. I'm trying to subscribe to the Page.lifecycleEvent in the below snippet:

with {:ok, _data} <- RPC.Page.enable(pid),
     #  :ok <- PageSession.subscribe(pid, "Page.loadEventFired", self()),
     :ok <- PageSession.subscribe(pid, "Page.lifecycleEvent", self()),
     {:ok, data} <- RPC.Page.navigate(pid, %{url: url}) do
    IO.inspect(data)
end

From my understanding on navigation the lifecycle event should fire, I'm also trying to listen for network idle events which the lifecycleEvent covers. But in both cases it never does anything. The Page.loadEventFired works properly but that doesn't wait for network idle.

nathanjohnson320 avatar Mar 03 '20 19:03 nathanjohnson320

better late than never, but for anyone else running into this issue while using this library, you can get around it by enabling the lifecycle events - as per the CDP - as such

PageSession.execute_command(page_pid, "Page.setLifecycleEventsEnabled", %{enabled: true},
  async: false
)

kernel-io avatar Apr 17 '25 08:04 kernel-io