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

sweb

v0.3.0

Published

High-level abstraction for selenium-webdriver

Readme

sweb

High-level abstraction for selenium-webdriver

Features:

  • Built with Selenium v3 and W3C WebDriver
  • Supports DOM API to explore page structure (via jsdom)
  • No setup: built in Chrome support (via chromedriver)
  • Flexibility: integrates with any test framework, node script, and selenium cloud provider.

Example

Smoke test for http://example.com using mocha and chai.

import { expect } from 'chai'
import { Browser } from 'sweb'

describe('smoke-tests', () => {
  let browser
  before(() => { browser = new Browser() })
  after(() => { browser.quit() })

  it('opens example.com', async () => {
    const page = await browser.open('example.com')
    expect(page.url).equal('http://example.com/')
    expect(page.title).equal('Example Domain')
    expect(page.document.links).length(1)
    expect(page.document.querySelector('a').href).equal('http://www.iana.org/domains/example')
    await page.click('a')
    expect(page.url).equal('http://www.iana.org/domains/reserved')
  })
})

Installation

Requires node >= 6.9 (because of selenium-webdriver)

$ yarn add -D sweb
$ npm i -D sweb

API

new Browser(opts = {})

Creates new Browser instance.

Available options:

  • screenhostOnError (default: false) - make automatic screenshot when sweb throws a custom error, for example on failed waitFor or click.
  • workDir (default: ${cwd}/.sweb) - specify directory for sweb's logs and screenshots. If folder does not exist, it will be created automatically.
  • driver - custom build of WebDriver, useful for running different browsers or for Browserstack/Saucelabs integration. Check custom drivers section for more details.

await browser.open(url)

Load url in browser and return Page instance.

Page instance has useful properties:

  • url - page url
  • document - similar to window.document, it's a jsdom instance with support of all DOM API methods.
  • title - page title
  • source - page html source
  • driver - WebDriver instance

await browser.quit()

Quit real browser.

await page.click(selector)

Perform click event to selector.

await page.type(selector, text)

Send user type input (combination of keydown, keypress, keyup for each character) to selector with text. To emulate special keys like ENTER or F12 use Key.

import { Browser, Key } from 'sweb'

const browser = new Browser()
const page = await browser.open('https://www.google.com')
await page.type('[name="q"]', `selenium webdriver npm${Key.ENTER}`)

await page.waitFor(selector, delay = 2000)

Wait for selector appears in html.

await page.screenshot(name)

Make screenshot of the page and store to ${browser.workDir}/${name}.png.

Custom drivers

driver option allows to pass custom selenium-webdriver configuration.

Firefox with geckodriver

import 'geckodriver'
import { Browser, Builder } from 'sweb'

const driver = new Builder().forBrowser('firefox').build()
const browser = new Browser({ driver })
const page = await browser.open('http://example.com')

Integration with Browserstack

import { Browser, Builder } from 'sweb'

const driver = new Builder()
  .usingServer('http://hub-cloud.browserstack.com/wd/hub')
  .withCapabilities({
    'browserName': 'chrome',
    'browserstack.user': browserStackUser,
    'browserstack.key': browserStackKey,
    'browserstack.debug': 'true',
    'build': 'First build'
  })
  .build()

const browser = new Browser({ driver })
const page = await browser.open('https://www.google.com')  

Integration with Saucelabs

import { Browser, Builder } from 'sweb'

const driver = new Builder()
  .usingServer('http://' + username + ':' + accessKey + '@ondemand.saucelabs.com:80/wd/hub')
  .withCapabilities({
    'browserName': 'chrome',
    'platform': 'Windows XP',
    'version': '43.0',
    username,
    accessKey
  })
  .build()

const browser = new Browser({ driver })
const page = await browser.open('http://example.com')

LICENSE

MIT