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

wv3-selectors

v1.0.0

Published

CommonJS CSS selector builder for websites, scraping, testing, and browser automation.

Readme

wv3-selectors

wv3-selectors is a CommonJS Node package for building website CSS selectors.

It is useful for:

  • Playwright scripts
  • Puppeteer scripts
  • scraping tools
  • browser automation
  • reusable selector maps
  • test locators based on CSS

Install

npm install wv3-selectors

Usage

const s = require('wv3-selectors');

const selector = s.compound(
  s.tag('button'),
  s.class('primary'),
  s.data('testid', 'save-button')
);

console.log(selector);
// button.primary[data-testid="save-button"]

Main helpers

Basic pieces

const s = require('wv3-selectors');

s.tag('button');
// button

s.id('login-form');
// #login-form

s.class('card');
// .card

s.attr('href');
// [href]

s.attr('href', '/pricing');
// [href="/pricing"]

s.data('testid', 'hero-title');
// [data-testid="hero-title"]

Combine selector parts

const s = require('wv3-selectors');

const button = s.compound(
  s.tag('button'),
  s.class('btn'),
  s.class('btn-primary'),
  s.attr('type', 'submit')
);

console.log(button);
// button.btn.btn-primary[type="submit"]

Relationships

const s = require('wv3-selectors');

s.descendant('main', '.card', 'a[href]');
// main .card a[href]

s.child('ul.menu', 'li.item');
// ul.menu > li.item

s.sibling('.title', '.badge');
// .title ~ .badge

s.adjacent('label', 'input');
// label + input

s.list('#hero', '.banner', 'main > section');
// #hero, .banner, main > section

Pseudo selectors

const s = require('wv3-selectors');

s.compound('li', s.nth(3));
// li:nth-child(3)

s.compound('article', s.not('.hidden'));
// article:not(.hidden)

s.compound('section', s.has('img'));
// section:has(img)

Chain builder

const s = require('wv3-selectors');

const selector = s
  .create()
  .tag('button')
  .class('primary')
  .data('testid', 'checkout')
  .attr('type', 'submit')
  .toString();

console.log(selector);
// button.primary[data-testid="checkout"][type="submit"]

Playwright example

const { chromium } = require('playwright');
const s = require('wv3-selectors');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');

  const saveButton = s
    .create()
    .tag('button')
    .data('testid', 'save-button')
    .toString();

  await page.click(saveButton);
  await browser.close();
})();

API

  • tag(name)
  • id(name)
  • class(name)
  • cls(name)
  • attr(name, value?, operator?)
  • data(name, value, operator?)
  • pseudo(name, value?)
  • nth(index)
  • nthOfType(index)
  • not(selector)
  • has(selector)
  • where(selector)
  • is(selector)
  • compound(...parts)
  • descendant(...selectors)
  • child(parent, child)
  • sibling(left, right)
  • adjacent(left, right)
  • list(...selectors)
  • create(initialSelector?)
  • escapeIdent(value)
  • escapeAttrValue(value)

Test

npm test

License

MIT