lib/commands/element.js
function (selector, hash, expected, res) {
    var deferred = Q.defer();
    var result = JSON.parse(res);

    // check if the expression matched any element
    if (result.value === -1) {
      this.events.emit('driver:message', {key: 'numberOfVisibleElements', hash: hash, selector: selector, expected: expected, value: 0});
    } else {
      this.events.emit('driver:message', {key: 'numberOfVisibleElements', selector: selector, expected: expected, hash: hash, value: result.value.length});
    }

    deferred.resolve();
    return deferred.promise;
  }
function (selector, hash, expected, res) {
    var deferred = Q.defer();
    var result = JSON.parse(res);

    // check if the expression matched any element
    if (result.value === -1) {
      this.events.emit('driver:message', {key: 'numberOfVisibleElements', hash: hash, selector: selector, expected: expected, value: 0});
    } else {
      this.events.emit('driver:message', {key: 'numberOfVisibleElements', selector: selector, expected: expected, hash: hash, value: result.value.length});
    }

    deferred.resolve();
    return deferred.promise;
  }
function ( selector , hash , expected , res ) { var deferred = Q . defer ( ) ; var result = JSON . parse ( res ) ; // check if the expression matched any element if ( result . value === - 1 ) { this . events . emit ( 'driver:message' , { key : 'numberOfVisibleElements' , hash : hash , selector : selector , expected : expected , value : 0 } ) ; } else { this . events . emit ( 'driver:message' , { key : 'numberOfVisibleElements' , selector : selector , expected : expected , hash : hash , value : result . value . length } ) ; } deferred . resolve ( ) ; return deferred . promise ; }
Sends out an event with the results of the `getNumberOfVisibleElements` call

@method _getNumberOfElementsCb
@param {string} selector Selector expression to find the element
@param {string} hash Unique hash of that fn call
@param {integer} expected Expected number of matched elements
@param {string} res Serialized JSON with the results of the getNumberOfVisibleElements call
@return {object} promise GetNumberOfElements promise
@private
Sends out an event with the results of the getNumberOfVisibleElements call