Class: Browserctl::Replay::Context
- Inherits:
-
Object
- Object
- Browserctl::Replay::Context
- Defined in:
- lib/browserctl/replay/context.rb
Overview
Per-page replay context carried by PageProxy during a workflow run generated from a recording.
Holds the recorded fingerprint for each selector that the workflow interacts with. When a selector-driven command fails with selector_not_found at replay time, the proxy looks up the fingerprint here and asks FingerprintMatcher to find a candidate in the live snapshot. The matched element’s stable ref is then re-used to retry the original command.
Drift events (rematches, threshold misses) are accumulated on the context so the surrounding workflow runner can render them into a drift report at end-of-run.
Defined Under Namespace
Classes: DriftEvent
Instance Attribute Summary collapse
-
#drift_events ⇒ Object
readonly
Returns the value of attribute drift_events.
Instance Method Summary collapse
- #fingerprint_for(selector) ⇒ Object
-
#initialize(fingerprints: {}) ⇒ Context
constructor
A new instance of Context.
- #record(command:, selector:, matched_ref: nil, score: nil, reason: nil) ⇒ Object
Constructor Details
#initialize(fingerprints: {}) ⇒ Context
Returns a new instance of Context.
23 24 25 26 |
# File 'lib/browserctl/replay/context.rb', line 23 def initialize(fingerprints: {}) @fingerprints = fingerprints @drift_events = [] end |
Instance Attribute Details
#drift_events ⇒ Object (readonly)
Returns the value of attribute drift_events.
21 22 23 |
# File 'lib/browserctl/replay/context.rb', line 21 def drift_events @drift_events end |
Instance Method Details
#fingerprint_for(selector) ⇒ Object
28 29 30 |
# File 'lib/browserctl/replay/context.rb', line 28 def fingerprint_for(selector) @fingerprints[selector] end |
#record(command:, selector:, matched_ref: nil, score: nil, reason: nil) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/browserctl/replay/context.rb', line 32 def record(command:, selector:, matched_ref: nil, score: nil, reason: nil) @drift_events << DriftEvent.new( command: command, selector: selector, matched_ref: matched_ref, score: score, reason: reason ) end |