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

doffy

v0.0.7

Published

a headless browser automation library with easy-use API

Downloads

6

Readme

doffy

CircleCI npm GitHub stars GitHub license

Doffy a headless browser automation library with easy-use API.

Doffy provide a few simple methods to simulate user action like goto click fill, which are useful for headless web testing and crawling.

Feature

  • Base on chrome headless, use Chrome Devtools Protocol, while Nightmare base on Electron and Casper is base on PhantomJS.
  • All Promise, all API of Doffy return a Promise

QuickStart

install chrome headless

Mac: chrome headless is shipped on chrome-canary, install: https://www.google.com/chrome/browser/canary.html

Linux: chrome headless is also shipped on chrome 59. so you can install chrome 59 to use headless mode.

# https://askubuntu.com/questions/79280/how-to-install-chrome-browser-properly-via-command-line
sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb  # Might show "errors", fixed by next line
sudo apt-get install -f

install doffy

# wait for npm publish

page automation:

import Doffy from '../src/doffy';
const doffy = new Doffy();

(async() => {
  await doffy.init();
  await doffy.goto('https://github.com/login');
  await doffy.screenshot('result/01-homepage.jpeg');
  await doffy.fill('#login_field', 'doffyjs');
  await doffy.fill('#password', 'doffy2017');
  await doffy.screenshot('result/02-fillaccount.jpeg');
  await doffy.click('[name="commit"]');
  await doffy.wait('.avatar');
  let isLogin = await doffy.visible('.avatar')
  isLogin && console.log('======== login success ========');
  await doffy.end(true);
})();

run mocha test

import Doffy from '../src/doffy';

const expect = require('chai').expect;
const doffy = new Doffy();

describe('test example', function() {

  before(async function() {
    try {
      await doffy.init();
      console.log('======== test begin ========');
    } catch(err) {
      console.error('error happen while init doffy', err);
    }
  });

  after(async function() {
    // runs after all tests in this block
    await doffy.end(true);
    console.log('====== test end ======');
  });

  it('open home page', async function() {
    await doffy.goto('https://www.baidu.com');
    let ret = await doffy.title();
    expect(ret.result.value).to.be.equal("百度一下,你就知道");
    await doffy.screenshot('temp/01.jpeg');
  });

  it('open signin dialog', async function() {
    await doffy.fill('#kw', 'github');
    await doffy.click('#su');
    let firstResult = await doffy.evaluate(() => {
      return document.querySelectorAll('.result h3')[0].innerText;
    });
    expect(firstResult).to.be.equal('GitHub · Build software better, together.官网');
    await doffy.screenshot('temp/02.jpeg');
  });

});

API

see wiki page => API doc please wait...

ChangeLog

2017.05.12

  • New

LICENSE

MIT