Skip to content

feat(inspector): XPath quote preference and XPath variations (AL-15521) - #22

Draft
aniket-kes wants to merge 1 commit into
AL-13652-appium-inspector-upgradefrom
AL-15521-xpath-quotes-and-variations
Draft

aniket-kes wants to merge 1 commit into
AL-13652-appium-inspector-upgradefrom
AL-15521-xpath-quotes-and-variations

Conversation

@aniket-kes

@aniket-kes aniket-kes commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

What

Two additions to the Selected Element panel, for AL-15521 (Barclays deal blocker, moving from SeeTest to App Live):

  1. XPath quotes toggle — "double" / 'single' under the locators table. With 'single', the xpath row and every variation use single quotes (//android.widget.Button[@resource-id='…']). Saved per browser (PREFERRED_XPATH_QUOTE); default stays double, so nothing changes for anyone who doesn't flip it.
  2. XPath variations — a collapsible list with a copy-on-click XPath per row: ID only, Type + ID, Type + <attr>, ID + <attr>, Indexed, inside the nearest uniquely-identified parent, full path from root. Android (resource-id, text, content-desc) and iOS (name, label, value).

Why

Barclays writes Cucumber Java; double-quoted XPaths need escaping inside a Java string. SeeTest also lets them choose between several XPaths for one element (full path vs. a short ID-based one), which the inspector doesn't offer — it shows a single "optimal" XPath.

Behaviour worth knowing

  • A value containing ' stays in double quotes (XPath 1.0 can't escape it); a value with both quote types uses concat().
  • Only variations that select exactly the chosen element are listed (checked against the page source in the browser).
  • Variations are copy-only. The device-facing locator list is untouched, so element lookup and Get Timing behave as before.
  • iOS full path drops <AppiumAUT>. The page source wraps the tree in it, but the device evaluates XPath from XCUIElementTypeApplication down: /AppiumAUT/… matched 0 elements on a real iPhone; without the prefix it matched 1.
  • The whole app is never offered as the "unique parent".
  • Rows are stacked (label line, then XPath) because the panel is ~264px wide inside App Live; a two-column table broke labels mid-word.

How it was verified

Where Device Variations checked on-device Result
App Automate Galaxy S23 / Android 13 232 (every element on screen) all exactly 1 match
App Automate iPhone 15 / iOS 17 24 sampled (full path, Indexed, parent) all exactly 1 match
App Live (local build served in place of the deployed one) Pixel 8 / Android 14 142 (39 elements), via App Live's devtools proxy all exactly 1 match
App Live iPhone 15 / iOS 17.3 82 (23 elements), via App Live's devtools proxy all exactly 1 match

Also checked in App Live: light theme, auto-attach, the toggle persisting across inspector restarts, sessions and platforms, and close → restart picking up a new bundle without ending the session.

Gates: npm run test:unit 191/191 (14 new in test/unit/xpath-variations.spec.js, incl. an exhaustive "every variation selects exactly this node" check on Android + iOS fixtures in both quote styles); eslint clean on the changed files (the reducer's existing import-order error is on v7 and left alone). Nightwatch @appium_inspector not run yet.

Implementation note

Shaped as two new files (utils/xpath-variations.js, SelectedElement/XPathVariations.jsx + .module.css) plus small edits in SelectedElement.jsx, the SessionInspector action/reducer and setting-defs.js, so the next upstream sync re-applies it cheaply (ADR-001). No postMessage, URL-param or window.AppLiveSessionId contract changes. Automation ids: #xpathQuoteToggle, #xpathVariations.

🤖 Generated with Claude Code

Barclays (deal blocker AL-15521) is moving from SeeTest to App Live and asked for
two locator-panel features:

- A "double" / 'single' toggle under the locators table. With 'single', every
  XPath attribute value in the locators table and the variations list uses single
  quotes, so the XPath drops into a Java string without escaping. The choice is
  saved per browser (PREFERRED_XPATH_QUOTE, same mechanism as the recorder's
  client framework); default stays double. A value containing an apostrophe keeps
  double quotes; one containing both uses concat().
- A collapsible "XPath variations" list: ID only, Type + ID, Type + <attr>,
  ID + <attr>, Indexed, inside the nearest uniquely-identified parent, and full
  path from root. Only variations that select exactly the chosen element are
  listed; they are copy-only and never sent to the device, so element lookup and
  Get Timing are unchanged.

The iOS full path drops the <AppiumAUT> wrapper from the page source: the device
evaluates XPath from XCUIElementTypeApplication down, and /AppiumAUT/... matched
nothing on a real iPhone. The whole app is never offered as the "unique parent".

Verified on real devices through App Automate (Galaxy S23 / Android 13, iPhone 15 /
iOS 17) and inside App Live (Pixel 8 / Android 14, iPhone 15 / iOS 17.3): every
variation for every element on screen matched exactly one element.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 68ebaa11-1e3c-4e86-bd73-5318a7e9e6b5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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