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 🙏

© 2024 – Pkg Stats / Ryan Hefner

puppet-strings

v5.0.4

Published

A better interface for common browser automation workflows

Downloads

150

Readme

puppet-strings

npm Build Status dependencies Status devDependencies Status

A better interface for common browser automation workflows

Example

import {
  openBrowser, closeBrowser, openTab, waitForNavigation,
  findElement, fillInElement, clickElement, evalInTab
} from 'puppet-strings'

async function run() {
  const browser = await openBrowser('chromium')
  const tab = await openTab(browser, 'https://google.com/ncr')

  const searchInput = await findElement(tab, '[name="q"]')
  await fillInElement(searchInput, 'Node.js')

  const searchButton = await findElement(tab, `input[value="I'm Feeling Lucky"]`)
  await clickElement(searchButton)
  await waitForNavigation(tab)

  const title = await evalInTab(tab, [], 'return document.title')
  console.log(title)

  await closeBrowser(browser)
}

run()

Usage

Installation

npm Package

Install puppet-strings by running

yarn add puppet-strings

Or, if yarn is not installed, run

npm install --save puppet-strings

Locally Installed Browsers

puppet-strings works with locally installed recent stable versions of Google Chrome, Chromium, and Electron on Linux, Docker, OSX, and Windows.

We also maintain vinsonchuong/javascript, a Docker image that includes the latest Current version of Node.js and Chrome (as google-chrome)

API

puppet-strings provides an interface consisting of three nouns (browser, tab, and element) and actions that take one of them as first argument. Each action returns a promise that is resolved when the action is finished.

Here are the actions puppet-strings provides:

Browser

Tab

  • getTabs: Gets the list of currently open tabs
  • openTab: Opens a url in a new tab and waits for it to fully load
  • closeTab: Closes a tab
  • resizeTab: Changes the size of the viewport of a tab
  • navigate: Navigates a tab to a new URL
  • waitForNavigation: Waits for a page load to complete
  • evalInTab: Evaluates code within a tab and returns the result
  • findElement: Find a DOM element on the page by CSS selector

Element

Extension

puppet-strings is designed to be open for extension but closed for modification.

You can create new actions that take a Browser, Tab, or Element as argument. Your new actions can reuse other actions and interact directly with the underlying Puppeteer objects.

If your project needs to modify an action provided by puppet-strings, you can duplicate that action and maintain your modifications as part of your project.

Published Extensions

  • openChrome(): Find or download a suitable version of Chrome for use with puppet-strings
  • openApp(): Compile and open a web application in Chrome