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

buster-selenium

v0.0.6

Published

Buster.js extension to work with selenium-webdriver, wd, or webdriverio.

Downloads

15

Readme

buster-selenium

Build Status

An extension for buster.js to make it easy to write functional tests with either selenium-webdriver, wd, and webdriverio.

This extensions is only for tests run in node environment.

Install

Installation is done using npm:

$ npm install buster-selenium

Usage

Add buster-selenium extension and corresponding options, to the buster.js config file:

var config = module.exports;

config["Browser tests"] = {
    rootPath: "../",
    tests: ["test/**/*.js"],
    extensions: [require('buster-selenium')],
    'buster-selenium': {
        // required, can be either selenium-webdriver or wd
        driver: 'selenium-webdriver'
    }
}

Write the tests! Please check the documentation of the webdriver module you choose to use. Remember to quit the browser!

var buster = require('buster');

buster.testCase('goToGoogle', {
    'Load google.com': function(){
        var browser = this.webdriver.browser();

        return browser.get('http://www.google.com').then(function(){
            return browser.getTitle();
        }).then(function(title) {
            assert.equals(title, 'Google');
        }).then(function(){
            browser.quit();
        });
    }
});

Go check out Examples of how to setup buster.js config and tests.

Configuration

  • driver - (string or function) - required, choose selenium-webdriver, wd, or webdriverio strings or define a function that returns anything you want to use as the driver.
  • config - (object) - optional, configuration for the webdriver library. Each library is slightly different.
  • timeout - (number) - optional, defaults to 10000. Define how long a test runs before it timesout. Extend the time of your tests if the webdriver-driven browser takes a really long time to complete tasks.

Example

{
    driver: function(config){
        return new require('someOtherWebdriver')(config);
    },
    config: {
        exampleOption: true,
        exampleOption2: false
    }
}

selenium-webdriver config

  • server - (string) - url to the Selenium Server/Hub.
  • desiredCapabilities - (object) - define capabilities for the browser

Note: If phantomjs is not found in $PATH variable, it may be necessary to define the path in desiredCapabilities.

Example

{
    server: 'http://localhost:4444',
    desiredCapabilities: {
        browserName: 'phantomjs',
        'phantomjs.binary.path': './node_modules/.bin/phantomjs'
    }
}

wd config

  • server - (string or object) - url or parameters to the Selenium Server/Hub. Check wd browser-initialization docs for examples
  • desiredCapabilities - (object) - define capabilities for the browser

Note: Defining path to phantomjs is not necessary.

Example

{
    server: 'http://localhost:444',
    desiredCapabilities: {
        browserName: 'phantomjs'
    }
}

webdriverio config

Refer to webdriverio options docs for an explanation of the config options.

Consider setting logLevel property to "silent" when using xml reporter.

Example (taken from a webdriverio example)

{
    desiredCapabilities: {
        browserName: 'chrome',
        version: '27',
        platform: 'XP'
    },
    host: 'hub.browserstack.com',
    port: 80,
    user : process.env.BROWSERSTACK_USERNAME,
    key: process.env.BROWSERSTACK_ACCESS_KEY,
    logLevel: 'silent',
}

Usage

Every test will be extended with a webdriver object with access to two properties.

  • driver - (object) - The require'd webdriver node module. Ex. require('wd'); or require('selenium-webdriver');
  • browser - (function) - A wrapper function around the webdrivers browser builder/initializer. Returns a browser session object with the desiredCapbilities config.

Example

// assume we are using selenium-webdriver
buster.testCase('google', {
    setUp: function(){
        // Get a browser session
        this.browser = this.webdriver.browser();
    },

    tearDown: function(){
        // Quit the browser session, you should clean up every time
        this.browser.quit();
    },

    'go to google.com': function(){
        // Go to the google webpage and assert that its true
        // Buster tests can accept promises!
        return browser.get('http://www.google.com').then(function(){
            assert(true);
        })
    }
});

Notes: wd

wd provides three (at the time of this writing) types of remote/browser objects. A regular continuation style, a promise, and a promise chain. To access them, pass the browser function a string!

// Give me the promise remote/browser!
this.browser = this.webdriver.browser('promise');

// or

// Give me the promise chain remote/browser!
this.browser = this.webdriver.browser('promiseChain');

// or

// Give me the regular continuation style remote/browser!
this.browser = this.webdriver.browser();

Refer to wd docs for more info.