feat(elements): Introduce @wdio/element package into the devtools project#215
Open
Winify wants to merge 9 commits into
Open
feat(elements): Introduce @wdio/element package into the devtools project#215Winify wants to merge 9 commits into
Winify wants to merge 9 commits into
Conversation
- Migrates browser element detection, accessibility tree, and mobile element locator generation from the MCP project into a standalone, reusable package
- Adds package to pnpm-workspace.yaml and registers path aliases in the root tsconfig.json for IDE resolution. - Fix linter
- Modify a11y tree query
- Empty selector → trailing '→ ' in output, unusable by agents, guard added at top of the interactive branch: skip the node entirely
- Option added to filter elements that are not visible (or not in viewport) - Introduce `statictext` role for visible text-bearing element (book titles, prices, promo copy) that otherwise have no a11y role (Suppress `statictext` children whose text is already included in the parent) - Extend inferPurpose() to consider same-depth structural siblings (img, heading, statictext) as context, and render `∈ parent` for all named interactive elements
- Use local fallback `getBestAndroidLocator(attrs)` and `getBestIOSLocator(attrs)` - Emit noisy mobile node roles from the snapshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
New package that extracts structured, AI-readable element trees from both browser pages and mobile apps.
What it does
getElements(browser, options)— unified API for both platforms. Returns{ elements, tree }with a flat interactable element list and the raw element tree for snapshot serialization.serializeWebSnapshot(tree, context?)— depth-indented text snapshot from a browser accessibility tree. Interactive elements render with→selectors, structural elements provide hierarchy and context, andstatictextcaptures visible text that has no interactivity.serializeMobileSnapshot(tree, context)— same format for Android/iOS page-source XML. Full Appium/WDIO locator pipeline wired in..instance(N)indexing for duplicate selectors.Capabilities
button,link,textbox,heading[2],img,statictext, …button,img,statictext,textbox,switch,list, …#id,tag.class,tag*=Text,[aria-label="…"], CSS-path fallback~content-desc,id:resource-id,android=new UiSelector()…,.instance(N)inViewportOnly: true(default)inViewportOnly: true(default)button "Wishlist" ∈ "The Housemaid" → …statictext "Google" ∈ "text_frame" → …statictextchildren suppressed.instance(N)suffix on repeated selectors→; label children provide∈Architecture
Snapshot Examples
mobile-snapshot--android-settings.txt
mobile-snapshot--apidemos.txt
web-snapshot--worldofbooks.txt