Module: WebkitRemote

Defined in:
lib/webkit_remote/top_level.rb,
lib/webkit_remote.rb,
lib/webkit_remote/rpc.rb,
lib/webkit_remote/event.rb,
lib/webkit_remote/client.rb,
lib/webkit_remote/browser.rb,
lib/webkit_remote/process.rb,
lib/webkit_remote/client/dom.rb,
lib/webkit_remote/client/page.rb,
lib/webkit_remote/client/input.rb,
lib/webkit_remote/client/console.rb,
lib/webkit_remote/client/network.rb,
lib/webkit_remote/client/runtime.rb,
lib/webkit_remote/client/dom_events.rb,
lib/webkit_remote/client/dom_runtime.rb,
lib/webkit_remote/client/page_events.rb,
lib/webkit_remote/client/console_events.rb,
lib/webkit_remote/client/network_events.rb

Overview

Top-level namespace.

Defined Under Namespace

Classes: Browser, Client, Event, Process, Rpc

Class Method Summary collapse

Class Method Details

.local(opts = {}) ⇒ WebkitRemote::Client

Launches a WebKit process locally, and sets up a debugger client for it.

Parameters:

  • opts (Hash) (defaults to: {})

    tweak the options below

Options Hash (opts):

  • port (Integer)

    the port used by the remote debugging server; the default port is 9292

  • timeout (Number)

    number of seconds to wait for the browser to start; the default timeout is 10 seconds

  • window (Hash<Symbol, Number>)

    set the :left, :top, :width and :height of the browser window; by default, the browser window is 256x256 starting at 0,0.

  • allow_popups (Boolean)

    when true, the popup blocker is disabled; this is sometimes necessary when driving a Web UI via JavaScript

  • headless (Boolean)

    if true, Chrome runs without any dependency on a display server

  • chrome_binary (String)

    path to the Chrome binary to be used; by default, the path is automatically detected

Returns:

  • (WebkitRemote::Client)

    a debugging client connected to a local WebKit process; the client will automatically stop the process when closed



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/webkit_remote/top_level.rb', line 10

def self.local(opts = {})
  # Use headless if no desktop is available.
  if !opts.has_key?(:headless) && (!ENV['DISPLAY'] || ENV['DISPLAY'].empty?)
    opts = { headless: true }.merge! opts
  end
  process = WebkitRemote::Process.new opts

  browser = process.start
  browser.stop_process = true
  client = WebkitRemote::Client.new tab: browser.tabs.first,
                                    close_browser: true
  client
end

.remote(opts = {}) ⇒ WebkitRemote::Client

Connects to a Webkit process, and sets up a debugger client for it.

Parameters:

  • opts (Hash) (defaults to: {})

    info on the browser to connect to

Returns:

  • (WebkitRemote::Client)

    a debugging client connected to the remote WebKit process; the connection will be automatically terminated when the debugging client is closed



30
31
32
33
34
35
36
# File 'lib/webkit_remote/top_level.rb', line 30

def self.remote(opts = {})
  browser = WebkitRemote::Browser.new opts
  # NOTE: connecting to the last tab to avoid internal tabs and whatnot
  client = WebkitRemote::Client.new tab: browser.tabs.last,
                                    close_browser: true
  client
end