Resolving a Promise in Protractor
<p>Strange issue I don't understand yet when trying to resolve (fulfill) my promise in Protractor.</p>

<p>Something is very wrong with the line <code>deferred.fulfill(rowData);</code>, as it's NOT returning the <code>row</code> data as I would expect.</p>

<p>In other words, <code>rowData.count()</code> in the lower function is fine, but when returned <code>row.count()</code> is failing.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>this.gridFunction = function (summaryData){


  var rowData = getGridRowByText(gridRows, name, text);
  
  rowData.then(function (row) {            
     // ** THROWS ERROR ** TypeError: row.count is not a function
     expect(row.count()).toEqual(3);

     row.map(function (cell) {  
        // iterate cell contents, compare with "summaryData"
     });

  });
}


 function getGridRowByText(gridRows, grid, text) {
        var deferred = protractor.promise.defer();
                
        var parentId = getParId();

        parentId.getAttribute("id").then(function (parentId) {

            // i.e. jquery $('.grid-wrapper.fluid-wrapper #rowId_21')
            var sel = '.grid-wrapper.fluid-wrapper #' + parentId;
            
            var rowData = element(by.css(sel)).all(by.repeater('column in  vm.sourceData.columns'));
            
            // EXPECT SUCCESSFULL !!!
            expect(rowData.count()).toEqual(19);
            
            
            deferred.fulfill(rowData);
        });
        return deferred.promise;
};</code></pre>
</div>
</div>
</p>

<p>Main question: am I NOT properly returning the fulfilled promise with the <code>rowData</code> object ?</p>

<p><strong>* UPDATE *</strong></p>

<p>My final solution  :</p>

<p>It doesn't actually solve my original problem of working with the Protractor Promise, but rather just a redesign of the logic.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>this.gridFunction = function (targetRowText){

  
  var result = gridRows.all(by.cssContainingText('span', targetRowText)).first();
  var parentId = result.all(by.xpath("./ancestor::div[starts-with(@id, 'rowId')]"));
        
        
  parentId.getAttribute("id").then(function (parentId) {            
      console.log('  (ROW-ID: ', parentId);
            
      // further iterations here...
  }
  
}</code></pre>
</div>
</div>
</p>

<p>thank you,
Bob</p>