Class: Browserctl::Snapshot::Fingerprint
- Inherits:
-
Object
- Object
- Browserctl::Snapshot::Fingerprint
- Defined in:
- lib/browserctl/snapshot/fingerprint.rb
Overview
Builds a per-element fingerprint that survives small DOM changes.
The fingerprint is later used by the replay layer to rematch an element when its recorded selector no longer resolves: score the candidate elements in the new DOM against the recorded fingerprint and pick the best match above a threshold.
Shape:
{
text: <accessible name>,
role: <ARIA role, explicit or implicit>,
neighbors: [<short text of nearby siblings>, ...],
position: { index: <int>, depth: <int> }
}
Constant Summary collapse
- NEIGHBOR_RADIUS =
siblings to capture on each side
2- NEIGHBOR_TEXT_LEN =
40
Instance Method Summary collapse
- #build(node) ⇒ Object
-
#initialize(ref_deriver: RefDeriver.new) ⇒ Fingerprint
constructor
A new instance of Fingerprint.
Constructor Details
#initialize(ref_deriver: RefDeriver.new) ⇒ Fingerprint
Returns a new instance of Fingerprint.
25 26 27 |
# File 'lib/browserctl/snapshot/fingerprint.rb', line 25 def initialize(ref_deriver: RefDeriver.new) @ref_deriver = ref_deriver end |
Instance Method Details
#build(node) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/browserctl/snapshot/fingerprint.rb', line 29 def build(node) { text: accessible_name(node), role: role(node), neighbors: neighbors(node), position: position(node) } end |