Class: Ferrum::Accessibility::AXNode

Inherits:
Object
  • Object
show all
Defined in:
lib/ferrum/accessibility/ax_node.rb

Overview

Represents an AXNode from the CDP Accessibility domain.

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ AXNode

Returns a new instance of AXNode.

Parameters:

  • params (Hash{String => Object})

    The parsed CDP AXNode attributes.



14
15
16
# File 'lib/ferrum/accessibility/ax_node.rb', line 14

def initialize(params)
  @params = deep_freeze(params)
end

Instance Method Details

#backend_dom_node_idInteger?

The id of the DOM node this AX node is backed by.

Returns:

  • (Integer, nil)


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

def backend_dom_node_id
  @params["backendDOMNodeId"]
end

#child_idsArray?

The ids of this AX node's children.

Returns:

  • (Array, nil)


86
87
88
# File 'lib/ferrum/accessibility/ax_node.rb', line 86

def child_ids
  @params["childIds"]
end

#descriptionString?

The AX node's accessible description.

Returns:

  • (String, nil)


35
36
37
# File 'lib/ferrum/accessibility/ax_node.rb', line 35

def description
  @params.dig("description", "value")
end

#ignored?Boolean

Whether the node is ignored by the accessibility tree.

Returns:

  • (Boolean)


58
59
60
# File 'lib/ferrum/accessibility/ax_node.rb', line 58

def ignored?
  @params["ignored"] == true
end

#ignored_reasonsArray?

The reasons the node is ignored, if any.

Returns:

  • (Array, nil)


65
66
67
# File 'lib/ferrum/accessibility/ax_node.rb', line 65

def ignored_reasons
  @params["ignoredReasons"]
end

#nameString?

The AX node's accessible name.

Returns:

  • (String, nil)


28
29
30
# File 'lib/ferrum/accessibility/ax_node.rb', line 28

def name
  @params.dig("name", "value")
end

#node_idString?

The AX node's id.

Returns:

  • (String, nil)


72
73
74
# File 'lib/ferrum/accessibility/ax_node.rb', line 72

def node_id
  @params["nodeId"]
end

#propertiesHash{String => Object}

ARIA/computed properties flattened to name => value.

Returns:

  • (Hash{String => Object})


49
50
51
52
53
# File 'lib/ferrum/accessibility/ax_node.rb', line 49

def properties
  @properties ||= Array(@params["properties"]).to_h do |property|
    [property["name"], property.dig("value", "value")]
  end.freeze
end

#roleString?

The AX node's role, e.g. "button".

Returns:

  • (String, nil)


21
22
23
# File 'lib/ferrum/accessibility/ax_node.rb', line 21

def role
  @params.dig("role", "value")
end

#to_hHash

The raw CDP AXNode hash.

Returns:

  • (Hash)


93
94
95
# File 'lib/ferrum/accessibility/ax_node.rb', line 93

def to_h
  @params
end

#valueString, ...

The AX node's current value.

Returns:

  • (String, Numeric, Boolean, nil)

    raw CDP AXValue.value; type varies by control



42
43
44
# File 'lib/ferrum/accessibility/ax_node.rb', line 42

def value
  @params.dig("value", "value")
end