Class: Unmagic::Browser::Driver::Remote

Inherits:
Base
  • Object
show all
Defined in:
lib/unmagic/browser/driver/remote.rb

Overview

A browser you already run somewhere else — browserless, a pool of your own, a Chrome started with --remote-debugging-port.

Examples:

Unmagic::Browser.new(driver: Unmagic::Browser::Driver::Remote.new(ws: "ws://browserless.internal:3000"))

Constant Summary

Constants inherited from Base

Base::DEFAULT_TIMEOUT, Base::WAIT_UNTIL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#close, #html, #markdown, #name, #open_connection, #pdf, #screenshot

Constructor Details

#initialize(ws: nil) ⇒ Remote

Returns a new instance of Remote.

Parameters:

  • ws (String) (defaults to: nil)

    a CDP websocket URL, e.g. "ws://browserless.internal:3000"

Raises:



18
19
20
21
22
23
24
25
# File 'lib/unmagic/browser/driver/remote.rb', line 18

def initialize(ws: nil)
  super()
  @ws = ws || ENV["BROWSER_WS_ENDPOINT"]
  return if @ws

  raise Error::Misconfigured,
    "The remote driver needs a websocket endpoint: Remote.new(ws: \"ws://...\") or $BROWSER_WS_ENDPOINT."
end

Instance Attribute Details

#wsString (readonly)

Returns the websocket endpoint this driver connects to.

Returns:

  • (String)

    the websocket endpoint this driver connects to



15
16
17
# File 'lib/unmagic/browser/driver/remote.rb', line 15

def ws
  @ws
end