Module: Ferrum

Defined in:
lib/ferrum/frame/dom.rb,
lib/ferrum.rb,
lib/ferrum/node.rb,
lib/ferrum/page.rb,
lib/ferrum/frame.rb,
lib/ferrum/mouse.rb,
lib/ferrum/dialog.rb,
lib/ferrum/target.rb,
lib/ferrum/browser.rb,
lib/ferrum/context.rb,
lib/ferrum/cookies.rb,
lib/ferrum/headers.rb,
lib/ferrum/network.rb,
lib/ferrum/version.rb,
lib/ferrum/contexts.rb,
lib/ferrum/keyboard.rb,
lib/ferrum/page/frames.rb,
lib/ferrum/frame/runtime.rb,
lib/ferrum/network/error.rb,
lib/ferrum/browser/client.rb,
lib/ferrum/browser/process.rb,
lib/ferrum/network/request.rb,
lib/ferrum/page/screenshot.rb,
lib/ferrum/network/exchange.rb,
lib/ferrum/network/response.rb,
lib/ferrum/browser/subscriber.rb,
lib/ferrum/browser/web_socket.rb,
lib/ferrum/network/auth_request.rb,
lib/ferrum/network/intercepted_request.rb

Overview

RemoteObjectId is from a JavaScript world, and corresponds to any JavaScript object, including JS wrappers for DOM nodes. There is a way to convert between node ids and remote object ids (DOM.requestNode and DOM.resolveNode).

NodeId is used for inspection, when backend tracks the node and sends updates to the frontend. If you somehow got NodeId over protocol, backend should have pushed to the frontend all of it’s ancestors up to the Document node via DOM.setChildNodes. After that, frontend is always kept up-to-date about anything happening to the node.

BackendNodeId is just a unique identifier for a node. Obtaining it does not send any updates, for example, the node may be destroyed without any notification. This is a way to keep a reference to the Node, when you don’t necessarily want to keep track of it. One example would be linking to the node from performance data (e.g. relayout root node). BackendNodeId may be either resolved to inspected node (DOM.pushNodesByBackendIdsToFrontend) or described in more details (DOM.describeNode).

Defined Under Namespace

Classes: Browser, BrowserError, Context, Contexts, Cookies, DeadBrowserError, Dialog, Error, Frame, Headers, JavaScriptError, Keyboard, Mouse, Network, NoExecutionContextError, NoSuchPageError, NoSuchTargetError, Node, NodeNotFoundError, NotImplementedError, Page, ScriptTimeoutError, StatusError, Target, TimeoutError

Constant Summary collapse

VERSION =
"0.6.2"

Class Method Summary collapse

Class Method Details

.elapsed_time(start = nil) ⇒ Object



91
92
93
# File 'lib/ferrum.rb', line 91

def elapsed_time(start = nil)
  monotonic_time - (start || @@started)
end

.mac?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/ferrum.rb', line 79

def mac?
  RbConfig::CONFIG["host_os"] =~ /darwin/
end

.monotonic_timeObject



95
96
97
# File 'lib/ferrum.rb', line 95

def monotonic_time
  Concurrent.monotonic_time
end

.mri?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/ferrum.rb', line 83

def mri?
  defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby"
end

.startedObject



87
88
89
# File 'lib/ferrum.rb', line 87

def started
  @@started ||= monotonic_time
end

.timeout?(start, timeout) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/ferrum.rb', line 99

def timeout?(start, timeout)
  elapsed_time(start) > timeout
end

.windows?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/ferrum.rb', line 75

def windows?
  RbConfig::CONFIG["host_os"] =~ /mingw|mswin|cygwin/
end

.with_attempts(errors:, max:, wait:) ⇒ Object



103
104
105
106
107
108
109
110
111
# File 'lib/ferrum.rb', line 103

def with_attempts(errors:, max:, wait:)
  attempts ||= 1
  yield
rescue *Array(errors)
  raise if attempts >= max
  attempts += 1
  sleep(wait)
  retry
end