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/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/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

Returns:

  • (WebkitRemote::Client)

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



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

def self.local(opts = {})
  # Use Xvfb if no desktop is available.
  if !opts.has_key?(:xvfb) && (!ENV['DISPLAY'] || ENV['DISPLAY'].empty?)
    opts = { xvfb: 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



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

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