Core API¶
The core layer provides the fingerprinting engine, similarity scoring, healing logic, and SQLite storage.
ElementFingerprint¶
breadcrumb.core.fingerprint.ElementFingerprint
dataclass
¶
Rich identity snapshot of a DOM element.
Attributes:
| Name | Type | Description |
|---|---|---|
tag |
str
|
HTML tag name, lowercased (e.g. "button", "input", "div"). |
text |
str
|
Visible text content, stripped and lowercased. |
attributes |
frozenset[tuple[str, str]]
|
Frozen set of (name, value) pairs for all HTML attributes. |
dom_path |
tuple[str, ...]
|
Tuple of ancestor tag names from root to this element. |
siblings |
tuple[str, ...]
|
Tuple of tag names of immediate sibling elements. |
bbox |
BoundingBox | None
|
Bounding box at fingerprint time, or None if not available. |
locator |
str
|
The original locator string used to find this element. |
test_id |
str
|
Identifier for the test that created this fingerprint. |
Source code in breadcrumb/core/fingerprint.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
from_dict
classmethod
¶
Create a fingerprint from a plain dictionary.
Useful for reconstructing fingerprints from storage or test fixtures. Handles type coercion (lists -> tuples/frozensets) automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary with fingerprint fields. At minimum requires 'tag'. All other fields have sensible defaults. |
required |
Returns:
| Type | Description |
|---|---|
ElementFingerprint
|
A new ElementFingerprint instance. |
Source code in breadcrumb/core/fingerprint.py
to_dict
¶
Serialize the fingerprint to a plain dictionary for storage.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary representation suitable for JSON serialization |
dict[str, Any]
|
and SQLite storage. |
Source code in breadcrumb/core/fingerprint.py
BoundingBox¶
breadcrumb.core.fingerprint.BoundingBox
dataclass
¶
Axis-aligned bounding box of an element's visual position.
Source code in breadcrumb/core/fingerprint.py
FingerprintStore¶
breadcrumb.core.storage.FingerprintStore
¶
SQLite-backed storage for fingerprints and healing events.
Usage::
store = FingerprintStore() # Uses .breadcrumb.db in cwd
store = FingerprintStore("path/to/db.sqlite")
store.save_fingerprint(fingerprint)
fp = store.load_fingerprint("test_login", "#login-btn")
The database is created automatically on first access.
Source code in breadcrumb/core/storage.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
save_fingerprint
¶
Save or update a fingerprint for a (test_id, locator) pair.
Called on passing test runs to keep the fingerprint database current.
Raises:
| Type | Description |
|---|---|
ValueError
|
If test_id or locator is empty. |
Source code in breadcrumb/core/storage.py
load_fingerprint
¶
Load a stored fingerprint for a (test_id, locator) pair.
Returns None if not found.
Source code in breadcrumb/core/storage.py
record_healing
¶
Record a healing event. Append-only for reporting.
Source code in breadcrumb/core/storage.py
get_healing_events
¶
Query healing events, optionally filtered by test and/or locator.
Returns list ordered by timestamp descending.
Source code in breadcrumb/core/storage.py
get_all_fingerprints
¶
Load all stored fingerprints.
Source code in breadcrumb/core/storage.py
delete_fingerprint
¶
Delete a stored fingerprint. Returns True if found and deleted.
Source code in breadcrumb/core/storage.py
clear
¶
Delete all fingerprints and healing events.
stats
¶
Return counts of fingerprints and healing events.
Source code in breadcrumb/core/storage.py
HealingEvent¶
breadcrumb.core.storage.HealingEvent
dataclass
¶
Record of a single healing occurrence.