Element identification — 12× performance improvement
Redesigned the shadow DOM traversal algorithm with efficient caching and reordered filter pipeline. Salesforce timeout errors stopped occurring entirely.
1,30,000 elements: 30s → 2.5s · Salesforce errors eliminated
The problem
ACCELQ's element identification was becoming a production bottleneck. On a Salesforce page with 1,30,000 elements, finding the correct element took 30 full seconds. This wasn't just slow — it was causing Salesforce test runs to hit session timeout errors, making automation unreliable.
At 50,000 elements (common for large enterprise SPAs), identification took 4,500 ms. As enterprises adopted heavier single-page applications, this trajectory was heading in the wrong direction.
What I built
Completely redesigned the element identification pipeline. Three specific changes drove most of the improvement:
1. Redesigned shadow DOM traversal — instead of exhaustive depth-first traversal across all shadow roots, used heuristic-guided search that explores the most likely sub-trees first based on element characteristics.
2. Shadow root caching — shadow roots are expensive to traverse; caching their traversed element sets eliminates redundant work on pages where automation runs repeatedly.
3. Reordered the filter pipeline — cheap filters (tag name, visibility) run first to eliminate candidates early; expensive checks (coordinate bounds, attribute matching) only run on surviving candidates.
Also implemented hybrid selectors in alternate IDs: multiple selector strategies captured per element, ranked by stability for use in self-healing.
Approaches considered
Architecture
Visibility pre-filter (fast) → shadow root cache lookup → heuristic sub-tree selection based on element characteristics → tag/type filter pass → attribute filter pass → coordinate bounds check on surviving candidates → result. Each stage independently benchmarked. Cache invalidated on DOM mutation events.
Result
1,30,000 elements: 30s → 2.5s (12× faster). 50,000 elements: 4,500ms → 500ms (9× faster). 20,000 elements: 900ms → 150ms. 5,000 elements: 105ms → 30ms. Salesforce "unexpected error page" — previously frequent during test runs — stopped occurring entirely after the improvement.