Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
### Changed

### Fixed
- Passing a node resolved on the previous page to `evaluate`, e.g. when the page navigates while Cuprite searches
within an element, raised `Ferrum::BrowserError: Argument should belong to the same JavaScript world as target
object`. It's `Ferrum::NodeNotFoundError` now, so callers can treat the node as stale and find it again
[rubycdp/cuprite#233]

### Removed

Expand Down
3 changes: 2 additions & 1 deletion lib/ferrum/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ def raise_browser_error(error)
# Node has disappeared while we were trying to get it
when "No node with given id found",
"Could not find node with given id",
"Inspected target navigated or closed"
"Inspected target navigated or closed",
"Argument should belong to the same JavaScript world as target object"
raise NodeNotFoundError, error
# Context is lost, page is reloading
when "Cannot find context with specified id"
Expand Down
12 changes: 12 additions & 0 deletions spec/frame/runtime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@

expect(elapsed).to be < Ferrum::Frame::Runtime::INTERMITTENT_SLEEP
end

it "raises NodeNotFoundError for a node resolved on the previous page" do
browser.go_to("/table")
node = browser.at_xpath(".//td")
object_id = browser.page.command("DOM.resolveNode", nodeId: node.node_id).dig("object", "objectId")

browser.go_to("/table")

expect do
browser.evaluate("arguments[0].textContent", { "objectId" => object_id })
end.to raise_error(Ferrum::NodeNotFoundError, /same JavaScript world/)
end
end

describe "#add_script_tag" do
Expand Down
Loading