Why this is tricky

A 320-cell table and a 20-level-deep chain of divs, both real stress tests for a locator strategy — a full XPath from the document root is brittle and slow to write by hand. The target in each case carries one stable attribute; find it directly instead of walking the tree.

1. Large table

40 rows × 8 columns. One cell has data-target="true" — find it directly rather than iterating every row.


2. Deeply nested DOM

20 levels of wrapper divs. The button at the bottom has id="deep-target" — a direct id/attribute selector reaches it in one step.

Initial state.