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

webdriverio-selenium-harness

v1.1.0

Published

A WebdriverIO and Selenium Test Harness. Useful for bolting on integration test suite.

Downloads

30

Readme

Build Status Code Climate Codacy Badge

WebdriverIO & Selenium Test Harness

Why

This test harness allows you to setup bootstrap your feature/intergration tests with WebdriverIO and Selenium. It makes setup and teardown trivial, especially for starting and stopping a local selenium server.

Installation

First you want to install the peerDependencies and then the package itself.

npm i -D webdriverio
npm i -D selenium-standalone
npm i -D webdriverio-selenium-harness

Usage

You can use the test harness in your test framework of choice.
Just require the module and call setup and teardown in your before and after hooks.

Example

// Mocha

var harness = require('webdriverio-selenium-harness')
var options = {}

describe('Feature', function () {
  before(function () {
    var self = this
    self.harnessState = harness.setup(options)
    return harnessState.then(function (state) {
      self.browser = state.browser
    })
  })
  
  after(function () {
    var self = this
    return self.harnessState.then(harness.teardown)
  })
  
  // Tests ...
})

Caveats

  • Make sure you have your Browsers or PhantomJS installed.
  • Install Selenium by running ./node_modules/.bin/selenium-standalone install.
    Reference: https://www.npmjs.com/package/selenium-standalone
  • Make sure if your tests ever crash that, teardown always run. Otherwise you may have processes left on.

API

Setup

setup takes an object of options for both webdriverio and selenium.
setup returns a Promise of harness state which contains the webdriverio client and the selenium process.

Options are namespaced by webdriverio and selenium.
Each of the options will reflect the APIs provided in these documents.

References

WebdriverIO

init
remote

Selenium

selenium

Custom
  • remoteSelenium
    Use if you want to the test harness to point to a remote selenium server.

Examples

Traditional

An example of how to use on your local.

var options = {
  custom: {},
  selenium: {
    seleniumArgs: []
  },
  webdriverio: {
    init: {},
    remote: {
      desiredCapabilities: {
        browserName: 'phantomjs' // chrome, firefox
      }
    }
  },
}

harness.setup(options).then(function (state) {
  var browser = state.browser
  var selenium = state.selenium
})
Continuous Integration

An example of how to use in CI.

Note
The Selenium instance in the harness state is a stub process when using remoteSelenium.
Make sure you have a Selenium server running when using remoteSelenium custom option.

var isCI = !!process.env.CI

var options = {
  custom: { remoteSelenium: isCI },
  selenium: {
    seleniumArgs: []
  },
  webdriverio: {
    init: {},
    remote: {
      desiredCapabilities: {
        browserName: 'phantomjs' // chrome, firefox
      }
    }
  },
}

harness.setup(options).then(function (state) {
  var browser = state.browser
  var selenium = state.selenium // stub process - not real.
})

Teardown

teardown takes harness state and then closes the webdriverio client and selenium process.
teardown will return a Promise of undefined.

Example

harness.teardown(state).then(function () {
  // etc
})

Peer Dependencies