Khai Dao
Khai Dao

Reputation: 55

how to get column headers and return to text list

Has anyone got any ideas on how to get a list of column header on the data grid. I have the issue that I can get text from the list of element on protractor. The return value always are promise and I don't know on Protractor how to get text on these promise before continue the next steps.

function getcolumnheaderlist(columnheader){
 var textlist = [];
  
 var promiselist = element.all(by.css('thead[role="rowgroup"] tr th a')).map(function (elmt) {
    return elmt.getText(); 
  });
  
  promiselist.then(function (array) {
  textlist.push(array);
  });
  
  console.log(textlist);  
}

As my code above, the console alway print out empty. How I can force the action "get text" excute before printing out on console?

Upvotes: 0

Views: 465

Answers (1)

alecxe
alecxe

Reputation: 474221

If you want to see the result or the resolve promises on the console, you need to put console.log() into then() function:

promiselist.then(function (headers) {
    console.log(headers);
});

Upvotes: 0

Related Questions