Git Product home page Git Product logo

nemo-screenshot's Introduction

nemo-screenshot

Nemo plugin which uses selenium-webdriver to take a screenshot

Register as "screenshot" (see below)

Build Status

Requirements

  • Lists nemo@^1.0.4 as a peerDependency

Usage

  • npm install --save-dev nemo-screenshot@^v1.0.0
  • Add this to your Nemo plugins configuration (adjust arguments according to where you want screenshots to be saved):
plugins: {
  screenshot: {
    module: 'nemo-screenshot',
    arguments: [reportPath {String}[, eventArray {Array}]]
  },
  /* other plugins */
},
driver: {
  // driver props
}

The plugin takes as argument the path to save the screenshots and an optional eventsArray. The events array can have one or more of the following elements.

  • "click" - Takes a screenshot everytime the user performs a click
  • "exception" - Takes a screenshot when an exception occurs

API

screenshot.snap

  • @argument filename {String} will save <report directory>/filename.png to the filesystem
  • @returns {Promise} resolves to a JSON object:
{
  "imageName": "myImage.png",
  "imagePath": "/path/to/image/"
  // this will be included optionally if Jenkins environment variables are present
  // "imageUrl": "jenkinsURL",
  // "archivedImageUrl": "jenkinsURL"
}

screenshot.done

This is a convenience wrapper around screenshot.snap which can accept a callback, e.g. a mocha done method

  • @argument filename {String} will save <report directory>/filename.png to the filesystem
  • @argument done {Function} errback function to execute after screenshot is saved (or if there is an error saving screenshot)
  • @argument err {Error} (optional) error associated with screenshot. image information will be attached to this error's stack trace for reporting purposes

Usage example:

  it('will do some stuff then take a screenshot', function (done) {
    nemo.somePlugin.someAction().then(function() {
      // success!
      nemo.screenshot.done('success', done);
    }, function (err) {
      // failure!
      nemo.screenshot.done('success', done, err);
    });
  });

screenshot.setCurrentTestTitle

If set, the test title will be used as the screenshot filename when an exception occurs. Default screenshot filename is ScreenShot_onException-[process_id]-[timestamp].png, which is not easy to identify the failing test case.

  • @argument testTitle {String} current test title

nemo-screenshot's People

Contributors

danbehar avatar gabrielcsapo avatar grawk avatar ibihim avatar jugend avatar kotsie avatar nikulkarni avatar pmpranav avatar samsel avatar

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.