rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.7k stars 122 forks source link

Setting content directly does not allow for use of DOM queries #304

Closed AlexMuir closed 1 year ago

AlexMuir commented 1 year ago

I have an issue when trying to set the content of a page using content=

Example (using Ferrum 0.12)

browser = Ferrum::Browser.new
page = @browser.create_page

# Works as expected
page.go_to 'https://google.com'
page.at_css("a") # => #<Ferrum::Node ... >

# Raises an exception and cannot find node
page.content = "<html><body><a href='#'>Test</a></body></html>"
page.at_css("a") # => Could not find node with given id (Ferrum::NodeNotFoundError)

# Yet the body has certainly updated - it's as though the DOM isn't refreshed
puts page.body # => "<html><head></head><body><a href=\"#\">Test</a></body></html>"
route commented 1 year ago

FIxed by https://github.com/rubycdp/ferrum/pull/310

AlexMuir commented 1 year ago

Fantastic, thanks!