npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wdio/elements

v1.1.0

Published

Element detection scripts for WebdriverIO

Readme

@wdio/elements

Element detection and locator generation for WebdriverIO — browser DOM querying, mobile page-source parsing, accessibility tree extraction, and AI-readable snapshots.

Install

npm install @wdio/elements

Requires webdriverio as a peer dependency (^9.0.0).

Usage

Unified entry point (auto-detects browser vs mobile)

import { getElements } from '@wdio/elements'

const result = await getElements(browser, { limit: 50, inViewportOnly: true })
// { total, showing, hasMore, elements, tree? }

Browser

import { getInteractableBrowserElements } from '@wdio/elements'

const elements = await getInteractableBrowserElements(browser, {
  includeBounds: true,
  inViewportOnly: true
})
import { getBrowserAccessibilityTree } from '@wdio/elements'

const nodes = await getBrowserAccessibilityTree(browser, { inViewportOnly: true })

Mobile

import { getMobileVisibleElements } from '@wdio/elements'

const elements = await getMobileVisibleElements(browser, 'ios', {
  includeBounds: true,
  includeContainers: false
})

For the raw JSON element tree alongside the flat list:

import { getMobileVisibleElementsWithTree } from '@wdio/elements'

const { elements, tree } = await getMobileVisibleElementsWithTree(browser, 'android')

AI-readable snapshots

import { serializeWebSnapshot, serializeMobileSnapshot } from '@wdio/elements'

const snapshot = await serializeWebSnapshot(browser, { includeBounds: true })
// or
const snapshot = await serializeMobileSnapshot(browser, 'android', { includeLocators: true })

Locator generation

import { generateAllElementLocators, xmlToJSON } from '@wdio/elements/locators'

const locators = generateAllElementLocators(pageSource, {
  platform: 'android',
  viewportSize: { width: 1080, height: 2340 }
})

API

getElements(browser, params)

Auto-detects platform and returns a unified result.

| Param | Type | Default | Description | |---|---|---|---| | inViewportOnly | boolean | true | Skip off-screen elements | | includeContainers | boolean | false | Include layout containers (mobile only) | | includeBounds | boolean | false | Include element bounding boxes | | limit | number | 0 | Max elements (0 = no limit) | | offset | number | 0 | Pagination offset |

getInteractableBrowserElements(browser, options)

Single querySelectorAll walk — returns flat list of interactable elements.

getBrowserAccessibilityTree(browser, options)

Single DOM walk returning the accessibility tree as a flat AccessibilityNode[].

getMobileVisibleElements(browser, platform, options)

Parses page source XML (2 HTTP calls total) and returns elements with generated locators.

getMobileVisibleElementsWithTree(browser, platform, options)

Same as above but also returns the raw JSONElement tree.

serializeWebSnapshot(browser, options) / serializeMobileSnapshot(browser, platform, options)

Generate AI-readable (TOON-format) snapshots for LLM consumption.

@wdio/elements/locators

Re-exports the full locator generation pipeline from @wdio/devtools-core:

  • xmlToJSON, xmlToDOM, evaluateXPath, checkXPathUniqueness
  • findDOMNodeByPath, parseAndroidBounds, parseIOSBounds
  • flattenElementTree, countAttributeOccurrences, isAttributeUnique
  • isInteractableElement, isLayoutContainer, hasMeaningfulContent
  • shouldIncludeElement, getDefaultFilters
  • getSuggestedLocators, getBestLocator, locatorsToObject
  • generateAllElementLocators

Types

export type {
  BrowserElementInfo, GetBrowserElementsOptions,
  MobileElementInfo, GetMobileElementsOptions,
  AccessibilityNode,
  VisibleElementsResult,
  WebSnapshotOptions, MobileSnapshotOptions
} from '@wdio/elements'

// From @wdio/elements/locators:
export type {
  ElementAttributes, JSONElement, Bounds,
  FilterOptions, UniquenessResult,
  LocatorStrategy, LocatorContext,
  ElementWithLocators, GenerateLocatorsOptions
} from '@wdio/elements/locators'