Class: Obxcura::Node
- Inherits:
-
Object
- Object
- Obxcura::Node
- Defined in:
- lib/obxcura/node.rb
Overview
A live handle to a DOM node inside a Frame. Backed by a CDP remote object, so reads run as function calls bound to that object and reflect the current DOM. Returned by Frame::DOM#at_css / #css.
Instance Attribute Summary collapse
-
#object_id ⇒ String
readonly
The CDP remote objectId backing this node.
Instance Method Summary collapse
-
#[](name) ⇒ String?
Read an attribute value.
-
#initialize(frame, object_id) ⇒ Node
constructor
A new instance of Node.
-
#outer_html ⇒ String
The node's serialized outer HTML.
-
#text ⇒ String
The visible text of the node and its descendants.
Constructor Details
#initialize(frame, object_id) ⇒ Node
Returns a new instance of Node.
13 14 15 16 |
# File 'lib/obxcura/node.rb', line 13 def initialize(frame, object_id) @frame = frame @object_id = object_id end |
Instance Attribute Details
#object_id ⇒ String (readonly)
Returns the CDP remote objectId backing this node.
9 10 11 |
# File 'lib/obxcura/node.rb', line 9 def object_id @object_id end |
Instance Method Details
#[](name) ⇒ String?
Read an attribute value.
27 28 29 |
# File 'lib/obxcura/node.rb', line 27 def [](name) @frame.call_on(@object_id, "function(name) { return this.getAttribute(name); }", [ name ]) end |
#outer_html ⇒ String
Returns the node's serialized outer HTML.
32 33 34 |
# File 'lib/obxcura/node.rb', line 32 def outer_html @frame.call_on(@object_id, "function() { return this.outerHTML; }") end |
#text ⇒ String
Returns the visible text of the node and its descendants.
19 20 21 |
# File 'lib/obxcura/node.rb', line 19 def text @frame.call_on(@object_id, "function() { return this.textContent; }") end |