visualreview-protractor.js
function takeScreenshot (name) {
  if(_disabled) {
    return q.resolve();
  }

  return browser.driver.controlFlow().execute(function () {

    return q.all([_getProperties(browser), _getMetaData(browser), browser.takeScreenshot(), _readRunIdFile()]).then(function (results) {
      var properties = results[0],
        metaData = results[1],
        compareSettings = _compareSettingsFn,
        png = results[2],
        run = results[3];

      if (!run || !run.run_id) {
        _throwError('VisualReview-protractor: Could not send screenshot to VisualReview server, could not find any run ID. Was initRun called before starting this test? See VisualReview-protractor\'s documentation for more details on how to set this up.');
      }

      return _client.sendScreenshot(name, run.run_id, metaData, properties, compareSettings, png)
        .catch(function (err) {
          _throwError('Something went wrong while sending a screenshot to the VisualReview server. ' + err);
        });
    });
  }.bind(this));
}
function takeScreenshot (name) {
  if(_disabled) {
    return q.resolve();
  }

  return browser.driver.controlFlow().execute(function () {

    return q.all([_getProperties(browser), _getMetaData(browser), browser.takeScreenshot(), _readRunIdFile()]).then(function (results) {
      var properties = results[0],
        metaData = results[1],
        compareSettings = _compareSettingsFn,
        png = results[2],
        run = results[3];

      if (!run || !run.run_id) {
        _throwError('VisualReview-protractor: Could not send screenshot to VisualReview server, could not find any run ID. Was initRun called before starting this test? See VisualReview-protractor\'s documentation for more details on how to set this up.');
      }

      return _client.sendScreenshot(name, run.run_id, metaData, properties, compareSettings, png)
        .catch(function (err) {
          _throwError('Something went wrong while sending a screenshot to the VisualReview server. ' + err);
        });
    });
  }.bind(this));
}
function takeScreenshot ( name ) { if ( _disabled ) { return q . resolve ( ) ; } return browser . driver . controlFlow ( ) . execute ( function ( ) { return q . all ( [ _getProperties ( browser ) , _getMetaData ( browser ) , browser . takeScreenshot ( ) , _readRunIdFile ( ) ] ) . then ( function ( results ) { var properties = results [ 0 ] , metaData = results [ 1 ] , compareSettings = _compareSettingsFn , png = results [ 2 ] , run = results [ 3 ] ; if ( ! run || ! run . run_id ) { _throwError ( 'VisualReview-protractor: Could not send screenshot to VisualReview server, could not find any run ID. Was initRun called before starting this test? See VisualReview-protractor\'s documentation for more details on how to set this up.' ) ; } return _client . sendScreenshot ( name , run . run_id , metaData , properties , compareSettings , png ) . catch ( function ( err ) { _throwError ( 'Something went wrong while sending a screenshot to the VisualReview server. ' + err ) ; } ) ; } ) ; } . bind ( this ) ) ; }
Instructs Protractor to create a screenshot of the current browser and sends it to the VisualReview server.
@param name the screenshot's name.
@returns {Promise}
Instructs Protractor to create a screenshot of the current browser and sends it to the VisualReview server .