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

grunt-selenium-server

v0.1.7

Published

Grunt task to start/stop a local Selenium standalon server.

Downloads

44

Readme

grunt-selenium-server

Start/stop a local Selenium standalon server.

Getting Started

npm install grunt-selenium-server --save-dev

Grunt config example (with default options):

module.exports = function (grunt) {
  grunt.loadNpmTasks('grunt-selenium-server');
  grunt.initConfig({
    'start-selenium-server': {
      dev: {
        options: {
          autostop: false,
          downloadUrl: 'https://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar',
          downloadLocation: os.tmpdir(),
          serverOptions: {},
          systemProperties: {}
        }
      }
    },
    'stop-selenium-server': {
      dev: {}
    }
  });
};

Running grunt-selenium-server

Grunt task example:

grunt.registerTask('devUI', 'run selenium server and phpunit', function() {
  grunt.task.run('start-selenium-server:dev', 'phpunit:dev', 'stop-selenium-server:dev');
});

Run:

grunt devUI

Stopping grunt-selenium-server

Selenium will need to be stopped after it has started.

Set the autostop option to true

The selenium proccess will stop when the grunt proccess ends.

'start-selenium-server': {
  dev: {
    options: {
      autostop: true,
      downloadUrl: 'https://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar'
    }
  }
}

Use grunt-force-task to force a task

Any tasks (expected) to fail will continue

grunt.registerTask('test', ['start-selenium-server:dev', 'force:mochaTest', 'stop-selenium-server:dev']);

Create custom grunt.fail handler

Kill selenium in case your grunt tasks fails before we reach 'stop-selenium-server':

var seleniumChildProcesses = {};
grunt.event.on('selenium.start', function(target, process) {
  grunt.log.ok('Saw process for target: ' +  target);
  seleniumChildProcesses[target] = process;
});

grunt.util.hooker.hook(grunt.fail, function() {
  // Clean up selenium if we left it running after a failure.
  grunt.log.writeln('Attempting to clean up running selenium server.');
  for (var target in seleniumChildProcesses) {
    grunt.log.ok('Killing selenium target: ' + target);
    try {
      seleniumChildProcesses[target].kill('SIGINT');
    } catch(e) {
      grunt.log.warn('Unable to stop selenium target: ' + target);
    }
  }
});

Notes:

  1. If you won't handle this event, if your phpunit (for example) will fail the selenium server process will remain active in the background.

  2. The "grunt.fail" event will be fired whenever any grunt task is failing. Thus you might want to consider using a more specific event related to the task that actually uses selenium server. i.e phpunit in the above example.