lib/commands/screenshot.js
function (path, pathname, hash, uuid, result) {
    var deferred = Q.defer();
    // replace base64 metadata
    var base64Data = JSON.parse(result).value.replace(/^data:image\/png;base64,/,'');
    // replace placeholders
    var realpath = this._replacePathPlaceholder(path + pathname);
    // check if we need to add a new directory
    this._recursiveMakeDirSync(realpath.substring(0, realpath.lastIndexOf('/')));
    // write the screenshot
    fs.writeFileSync(realpath, base64Data, 'base64');
    this.events.emit('driver:message', {key: 'screenshot', value: realpath, uuid: hash, hash: hash});
    deferred.resolve();
    return deferred.promise;
  }
function (path, pathname, hash, uuid, result) {
    var deferred = Q.defer();
    // replace base64 metadata
    var base64Data = JSON.parse(result).value.replace(/^data:image\/png;base64,/,'');
    // replace placeholders
    var realpath = this._replacePathPlaceholder(path + pathname);
    // check if we need to add a new directory
    this._recursiveMakeDirSync(realpath.substring(0, realpath.lastIndexOf('/')));
    // write the screenshot
    fs.writeFileSync(realpath, base64Data, 'base64');
    this.events.emit('driver:message', {key: 'screenshot', value: realpath, uuid: hash, hash: hash});
    deferred.resolve();
    return deferred.promise;
  }
function ( path , pathname , hash , uuid , result ) { var deferred = Q . defer ( ) ; // replace base64 metadata var base64Data = JSON . parse ( result ) . value . replace ( / ^data:image\/png;base64, / , '' ) ; // replace placeholders var realpath = this . _replacePathPlaceholder ( path + pathname ) ; // check if we need to add a new directory this . _recursiveMakeDirSync ( realpath . substring ( 0 , realpath . lastIndexOf ( '/' ) ) ) ; // write the screenshot fs . writeFileSync ( realpath , base64Data , 'base64' ) ; this . events . emit ( 'driver:message' , { key : 'screenshot' , value : realpath , uuid : hash , hash : hash } ) ; deferred . resolve ( ) ; return deferred . promise ; }
Sends out an event with the results of the `screenshot` call
and stores the screenshot in the filesystem

@method _screenshotCb
@param {string} path Root directory path
@param {string} pathname Pathname of the screenshot path
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn call
@param {string} result Serialized JSON result of the screenshot call
@return {object} promise Screenshot promise
@private
Sends out an event with the results of the screenshot call and stores the screenshot in the filesystem