From 5ca5e9ed5e9ac8be580589e234aadc1de6929bc0 Mon Sep 17 00:00:00 2001 From: Dmitry Vorotilin Date: Sat, 3 Aug 2024 12:55:49 +0300 Subject: [PATCH] fix: Page.frameStoppedLoading should not wait for document_node_id response --- CHANGELOG.md | 1 + lib/ferrum/page.rb | 4 +++- lib/ferrum/page/frames.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b44d47f..0436134d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - `:ws_url` option is now used without modifications WYSIWYG. - `Network.requestWillBeSent` callback didn't handle params in a type-safe way +- `Page.frameStoppedLoading` callback shouldn't wait for document_node_id response ### Removed diff --git a/lib/ferrum/page.rb b/lib/ferrum/page.rb index 8f689ae4..563b585c 100644 --- a/lib/ferrum/page.rb +++ b/lib/ferrum/page.rb @@ -391,7 +391,9 @@ def use_authorized_proxy? use_proxy? && @proxy_user && @proxy_password end - def document_node_id + def document_node_id(async: false) + return client.command("DOM.getDocument", async: true, depth: 0) if async + command("DOM.getDocument", depth: 0).dig("root", "nodeId") end diff --git a/lib/ferrum/page/frames.rb b/lib/ferrum/page/frames.rb index 066ea10d..07e1db92 100644 --- a/lib/ferrum/page/frames.rb +++ b/lib/ferrum/page/frames.rb @@ -128,7 +128,7 @@ def subscribe_frame_stopped_loading # node will change the id and all subsequent nodes have to change id too. if @main_frame.id == params["frameId"] @event.set if idling? - document_node_id + document_node_id(async: true) end frame = @frames[params["frameId"]]