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

webdriveerio

v0.1.5

Published

webdriverJS + cheerio

Downloads

10

Readme

webdriveerio (webdriverJS + cheerio)

This module is a cheerio JQuery core implementation binded with a webdriverJS driver. With webdriveerio you can manipulate (like JQuery) HTML nodes from a web site page source code, and trigger actions over them like in a real browser, using webdriverJS over a selenium server.

You have a webdriverJS driver with a new command called "query". You can call this command with a selector and a callback that receive a "list" of element getting from the page loaded on the driver. Each of this elements are extended with the action methods that the webdriverJS driver has:

addValue
buttonClick
clearElement
click
doubleClick
dragAndDrop
moveToObject
setValue

These methods are the same as the dirver methods but without selector argument (css selector), because the target element is defined by the node on which the method was called, so you do not need to pass a selector. This allow you to write code to programatically select nodes and perform actions over them, instead of being limited to select them using css selectors only.

How to install it

npm install webdriveerio

Example

In the examples folder you'll find test.js file that search into checkbox-list.html some checkboxes and click the ones that match a rule (amount of "things" between 5 and 12).


var wd = require('webdriveerio');

var options = { desiredCapabilities: { browserName: 'chrome' } };

var driver = wd.remote(options);


// EXAMPLE:
// we will clck only checkboxes with an amount of things between 5 and 12;


driver
    .init()
    .url('file:///' + __dirname + '/checkbox_list.html') 
    .query('form input', function(err, $inputs, $) { 
        // you could add a pause between actions, calling "query" like this:
        // .query('form input', 500, function(err, $inputs, $) { 
        // 500 = milliseconds of pause between actions ("click" action in this example)
        
        $inputs.each(function(i,e){
        	
        	var $field = $(e);
            var amount = parseInt($field.next().text().split(' ')[0]);

            if (amount >= 5 && amount <= 12 ) {
                
                // just call click over the element and driver will click the element in the real browser
                $field.click(); 
            
            }
        });
    }) 
    .pause(10000, function(){})
    .end();

The above code click a selection of items, iterating over inputs and programatically decide wich has to be clicked depending on the weight of a number into the text of the label. It could not be posible using css selectors only.

The list of checkboxes is like this:

    ...
    
	<form>
		<input type="checkbox"></input><label>12 things</label><br>
		<input type="checkbox"></input><label>20 things</label><br>
		<input type="checkbox"></input><label>3 things</label><br>
		<input type="checkbox"></input><label>5 things</label><br>
		<input type="checkbox"></input><label>8 things</label><br>
		<input type="checkbox"></input><label>14 things</label><br>
	</form>

    ...

So test.js will click on "12 things", "5 things" and "8 things" checkboxes.