Class: Webpipe::BrowserResource

Inherits:
Object
  • Object
show all
Defined in:
lib/webpipe/browser.rb

Overview

Factory for browser sessions, exposed as client.browser.

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ BrowserResource

Returns a new instance of BrowserResource.



7
8
9
# File 'lib/webpipe/browser.rb', line 7

def initialize(http)
  @http = http
end

Instance Method Details

#create(url: nil, cookie: nil, proxy: nil, session_name: nil) ⇒ Object

Create a session. It starts asynchronously — call wait_until_running before sending commands for a controlled experience.



13
14
15
16
17
18
# File 'lib/webpipe/browser.rb', line 13

def create(url: nil, cookie: nil, proxy: nil, session_name: nil)
  body = drop_nil(url: url, cookie: cookie, proxy: proxy, session_name: session_name)
  info = @http.post("/api/v1/browser", body)
  BrowserSession.new(@http, id: info["id"], status: info["status"], url: info["url"],
                            session_name: info["session_name"], expires_at: info["expires_at"])
end