Giter Site home page Giter Site logo

grunt-selenium-server's Introduction

grunt-selenium-server

Start/stop a local Selenium standalon server.

Getting Started

npm install grunt-selenium-server --save-dev
grunt.loadNpmTasks('grunt-selenium-server');

Grunt config example (with default options):

'start-selenium-server': {
  dev: {
    options: {
      downloadUrl: 'https://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar',
      downloadLocation: '/tmp',
      serverOptions: {},
      systemProperties: {}
    }
  }
},
'stop-selenium-server': {
  dev: {

  }
}

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

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('SIGTERM');
                }
                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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.