Class: Puppeteer::Accessibility
- Inherits:
-
Object
- Object
- Puppeteer::Accessibility
- Defined in:
- lib/puppeteer/accessibility.rb,
sig/puppeteer/accessibility.rbs
Overview
rbs_inline: enabled
Defined Under Namespace
Classes: AXNode, SerializedAXNode
Instance Method Summary collapse
- #initialize(frame) ⇒ Object constructor
- #snapshot(interesting_only: true, include_iframes: false, root: nil) ⇒ SerializedAXNode?
Constructor Details
#initialize(frame) ⇒ Object
21 22 23 |
# File 'lib/puppeteer/accessibility.rb', line 21 def initialize(frame) @frame = frame end |
Instance Method Details
#snapshot(interesting_only: true, include_iframes: false, root: nil) ⇒ SerializedAXNode?
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/puppeteer/accessibility.rb', line 29 def snapshot(interesting_only: true, include_iframes: false, root: nil) response = @frame.client.( 'Accessibility.getFullAXTree', frameId: @frame.id, ) backend_node_id = describe_backend_node(root) if root default_root = AXNode.create_tree(@frame, response.fetch('nodes', [])) return nil unless default_root populate_iframes(default_root, interesting_only: interesting_only) if include_iframes needle = default_root if backend_node_id needle = default_root.find do |node| node.payload['backendDOMNodeId'] == backend_node_id end end return nil unless needle return serialize_tree(needle).first unless interesting_only interesting_nodes = Set.new collect_interesting_nodes(interesting_nodes, default_root, false) serialize_tree(needle, interesting_nodes).first end |