parseXPath stripped only a trailing positional predicate when computing
the step name, so IFRAME_STEP_RE (/^i?frame(?:\[\d+])?$/) recognized
iframe[2] but not iframe[@name='main']. Deep XPaths that selected the
iframe by attribute never crossed the frame boundary: the remaining path
was resolved in the parent frame and failed.
Strip all bracketed predicates for the step name in both parseXPath
(deepLocator) and parseXPathToSteps (a11y focus selectors), so any
iframe/frame step hops; hop selectors keep their full raw predicates
(Closes browserbase#3416)
Amp-Thread-ID: https://ampcode.com/threads/T-01a1bd90-aa00-7234-b10d-723391130866
Co-authored-by: Amp <[email protected]>
why
Deep XPaths that select an iframe by an attribute predicate never crossed the frame boundary.
parseXPathstripped only a trailing positional predicate when computing the step name, soIFRAME_STEP_RErecognizediframe[2]but notiframe[@name='main']—planDeepXPathTarget("//iframe[@name='main']//button")kept the iframe step in the final selector and resolved it as an element in the parent frame, failing even though the target exists inside the iframe. Positional form (//iframe[1]//button) worked.Closes #3416
what changed
parseXPath(understudy/deepLocator.ts) andparseXPathToSteps(understudy/a11y/snapshot/focusSelectors.ts) now strip all bracketed predicates when computing the step name, so anyiframe/framestep is recognized as a hop regardless of how it is selected.IFRAME_STEP_REsimplified to/^i?frame$/i— both call sites feed it predicate-stripped names.buildXPathFromStepsstill uses the raw step text, so predicates stay in the hop selector and the correct iframe element is still selected.test plan
packages/extension/tests/deep-locator.test.ts: attribute-predicate hop (//iframe[@name='main']//button), mixed positional+attribute hop (//iframe[2][@title='content']//button), and a predicate-free hop regression case. All hop selectors preserve their raw predicates.pnpm --filter ./packages/extension test:unit→ 73 files / 1191 tests passing, extension typecheck clean.Summary by cubic
Deep XPaths selecting an iframe by attribute predicate (e.g.
//iframe[@name='main']//button) now cross the frame boundary; previously only positional predicates like//iframe[1]worked, and attribute-selected iframes resolved against the parent frame and failed. Closes #3416.deepLocator.tsandfocusSelectors.ts, so anyiframe/framestep is recognized as a hop.Written for commit a7ab255. Summary will update on new commits.