title: How to fulfill a promise with Nightwatch
body: <p>I am switching from Protractor to Nightwatch.js, and I am facing some difficulties with the way Nightwatch handles the promises.</p>
  
  <p>To give an example, I am trying to count the number of element satisfying a given criterion. The count function is in a page object, so separated from the test itself:</p>
  
  <p>The page object command:</p>
  
  <pre><code>    countToDoList: function(browser) {
          browser.elements('css selector', "input[ng-model='todo.done']", function(result){
              return result.value.length;
          });
      }
  </code></pre>
  
  <p>and the call in the test:</p>
  
  <pre><code>'Angular - 1' : function(browser) {
    var angular = browser.page.angularPO();
    var mainPage = angular.section.main;
  
    angular.openMainPage(browser);
    var countToDoBoxes = 0;
  
    countToDoBoxes = mainPage.countToDoList(browser);
    console.log("countToDoBoxes = " + countToDoBoxes);
  
    browser.end();
  }
  </code></pre>
  
  <p>This returns "countToDoBoxes = undefined". And based on my (short) experience with Protractor, I assume that this is due to the function not fulfilling the promise, when it's passed to "countToDoBoxes".</p>
  
  <p>Is there a way to make this work? </p>