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

Fix: Safe call body method (DOM) when page is empty #522

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

Mihoid
Copy link
Contributor

@Mihoid Mihoid commented Feb 19, 2025

In some cases method body (DOM) can raise an exception. It happens when page is empty and there is no html
e.g.

=> browser = ::Ferrum::Browser.new
=> browser.goto('https://somesitewithemptypage.com') # <—— here we receive empty page
=> browser.body 
=> 
Ferrum::JavaScriptError: TypeError: Cannot read properties of null (reading 'outerHTML') |  

This PR will add safe call method body for reducing errors

@Mihoid Mihoid force-pushed the fix/page-safe-call branch 2 times, most recently from 67d0baf to 01fa6ca Compare February 19, 2025 20:44
@@ -517,6 +517,6 @@
%r{Request to http://.*/with_js failed \(net::ERR_INTERNET_DISCONNECTED\)}
)

expect(page.at_css("body").text).to match("No internet")
Copy link
Contributor Author

@Mihoid Mihoid Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes are a little bit confusing me 🤔

@Mihoid Mihoid force-pushed the fix/page-safe-call branch from 01fa6ca to f22da55 Compare February 19, 2025 20:51
@route route merged commit 486a64a into rubycdp:main Feb 20, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants