Class: Coelacanth::Client::Ferrum
- Defined in:
- lib/coelacanth/client/ferrum.rb
Overview
Coelacanth::Client
Instance Method Summary collapse
- #get_response(url = nil) ⇒ Object
- #get_screenshot ⇒ Object
-
#initialize(url, config = Coelacanth.config) ⇒ Ferrum
constructor
A new instance of Ferrum.
Methods inherited from Base
Constructor Details
#initialize(url, config = Coelacanth.config) ⇒ Ferrum
Returns a new instance of Ferrum.
8 9 10 11 |
# File 'lib/coelacanth/client/ferrum.rb', line 8 def initialize(url, config = Coelacanth.config) super(url, config) remote_client.goto(url) end |
Instance Method Details
#get_response(url = nil) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/coelacanth/client/ferrum.rb', line 13 def get_response(url = nil) @status_code = remote_client.network.status wait_for_network_idle body = remote_client.body body rescue => e raise sanitized_remote_client_error(e) end |
#get_screenshot ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/coelacanth/client/ferrum.rb', line 22 def get_screenshot tempfile = Tempfile.new wait_for_network_idle remote_client.screenshot(path: tempfile.path, format: "png") File.read(tempfile.path) rescue => e tempfile.close raise sanitized_remote_client_error(e) end |