Module: Ferrum

Defined in:
lib/ferrum/frame/dom.rb,
lib/ferrum.rb,
lib/ferrum/node.rb,
lib/ferrum/page.rb,
lib/ferrum/rbga.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/browser/xvfb.rb,
lib/ferrum/frame/runtime.rb,
lib/ferrum/network/error.rb,
lib/ferrum/browser/client.rb,
lib/ferrum/browser/command.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/browser/options/base.rb,
lib/ferrum/network/auth_request.rb,
lib/ferrum/browser/options/chrome.rb,
lib/ferrum/browser/options/firefox.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, CyclicObject, DeadBrowserError, Dialog, Error, Frame, Headers, JavaScriptError, Keyboard, Mouse, Network, NoExecutionContextError, NoSuchPageError, NoSuchTargetError, Node, NodeIsMovingError, NodeNotFoundError, NotImplementedError, Page, PendingConnectionsError, ProcessTimeoutError, RGBA, ScriptTimeoutError, StatusError, Target, TimeoutError

Constant Summary collapse

VERSION =
"0.10.1"

Class Method Summary collapse

Class Method Details

.elapsed_time(start = nil) ⇒ Object



125
126
127
# File 'lib/ferrum.rb', line 125

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

.mac?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/ferrum.rb', line 113

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

.monotonic_timeObject



129
130
131
# File 'lib/ferrum.rb', line 129

def monotonic_time
  Concurrent.monotonic_time
end

.mri?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/ferrum.rb', line 117

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

.startedObject



121
122
123
# File 'lib/ferrum.rb', line 121

def started
  @@started ||= monotonic_time
end

.timeout?(start, timeout) ⇒ Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/ferrum.rb', line 133

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

.windows?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/ferrum.rb', line 109

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

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



137
138
139
140
141
142
143
144
145
# File 'lib/ferrum.rb', line 137

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