Class: Browserctl::SnapshotBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/browserctl/server/snapshot_builder.rb

Constant Summary collapse

INTERACTABLE =
%w[a button input select textarea
[role=button] [role=link] [role=menuitem]].freeze
ATTRS =
%w[type name placeholder href aria-label role].freeze

Instance Method Summary collapse

Instance Method Details

#call(page) ⇒ Object



11
12
13
14
15
# File 'lib/browserctl/server/snapshot_builder.rb', line 11

def call(page)
  doc = Nokogiri::HTML(page.body)
  ref = 0
  doc.css(INTERACTABLE.join(",")).map { |el| element_entry(el, ref += 1) }
end