I am playing around with capybara/poltergeist perfect duo, but I am having trouble to properly debugging. I was testing a simple script:
logger = Logger.new "./log/who-scored-com.log"
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, js_errors: false,
debug: true,
logger: logger)
end
browser = Capybara.current_session
browser.visit 'https://www.whoscored.com/LiveScores'
browser.save_page 'page.html'
I am expecting that the script grap the page normally and saves it, but the page is empty and this is returned:
`Capybara::Poltergeist::StatusFailError: Capybara::Poltergeist::StatusFailError
from /home/vagrant/local/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/poltergeist-1.9.0/lib/capybara/poltergeist/browser.rb:351:in `command'
from /home/vagrant/local/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/poltergeist-1.9.0/lib/capybara/poltergeist/browser.rb:34:in `visit'`
Now, this don't give me nothing about this error. I catch the exception and print it and it gives me:
"Request to 'https://www.whoscored.com/LiveScores' failed to reach server, check DNS and/or server status"
Even if I have no idea why the address do not respond for capybara (and any hint would be appreciate :) ) I don't understand why the :debug
options used in configuration doesn't seem to give me no info
You have a couple of issues
the poltergeist logger option is defined as '(Object responding to puts) - The ruby 2.3.0 standard library Logger object doesnt respond to puts so it's not valid.
You're example doesn't have Capybara.current_driver = :poltergeist
so I'm not sure if it is actually using the driver you're configuring there or a previously defined one (I would have expected an error on the Logger object if it was)
debug: true
will add debugging for poltergeist to the log, but there is also debugging info from phantomjs. That is generated by passing phantomjs_options: ['--debug=true'], phantomjs_logger: <an IO object - again not a Logger object>
to the driver
The error you're actually hitting is the connection being refused due to not being able to negotiate an ssl protocol - to fix it add the required ssl protocol as a phantomjs option - `phantomjs_options: ['--ssl-protocol=TLSv1.2']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With