Skip to content

feat(strict-mode): render nested matches as tree in fetchDetails() - #5710

Merged
DavertMik merged 2 commits into
4.xfrom
feat/multiple-elements-tree-output
Sep 10, 2026
Merged

feat(strict-mode): render nested matches as tree in fetchDetails()#5710
DavertMik merged 2 commits into
4.xfrom
feat/multiple-elements-tree-output

Conversation

@DavertMik

@DavertMik DavertMik commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Strict-mode failures list every matched element flat, so when one match is nested inside another the relationship is invisible.

This change derives nesting from absolute-XPath segment prefixes and renders child matches indented with an explicit parent label, keeping global numbering (numbers still map to grabWebElements()[i] / elementIndex). Flat output for non-nested matches is byte-identical to before.

Multiple elements (4) found for ".item" in strict mode.
  1. > //html/body/div[1]
     <div class="item">…
    2. (inside 1.) > //html/body/div[1]/div[1]
       <div class="item">…
    3. (inside 1.) > //html/body/div[1]/div[2]
       <div class="item">…
  4. > //html/body/footer
     <footer>…</footer>
  • All logic in lib/helper/errors/MultipleElementsFound.js (pure splitXPath / isAncestorXPath / computeParents / computeDepths / formatTree helpers, exported for tests); no extra browser calls, no helper changes
  • The (inside N.) label names the immediate parent's match number, so deeper nesting reads (inside 2.), etc.
  • Failed lookups render as label-free roots without breaking ancestry; 10-item cap and footer unchanged
  • Tests: new test/unit/multiple_elements_found_test.js (7 tests), ESLint clean

@DavertMik
DavertMik merged commit 460c26f into 4.x Sep 10, 2026
15 of 17 checks passed
@DavertMik
DavertMik deleted the feat/multiple-elements-tree-output branch September 10, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant