将 table 中每一行的列中的值收集到量角器中的数组中

Gathering a value from a column from each row from a table into an array in protractor

正在为 Angular 应用程序编写端到端测试,但我似乎无法理解异步编程和承诺。 我试图从第一列的每一行中获取值,并将其添加到数组中,最终将其从高到低排序以获得最高值。 我在解决 rows.each 的承诺时遇到了一些问题,错误消息是: 'TypeError: undefined is not a function'

//This function will fetch the highest ID from the columns
this.getHighestScheduleId = (function(){
    //Array to collect the ID's in
    var idArray = [];
    //Collects all the rows in our table
    var rows = $$('#schedulesData');
    //Goes through each row
    rows.each(function(row){
        //Collect all the row's elements in rowElems
        var rowElems = row.$$('td');
        console.log(rowElems[0].getText());
    });
});

map() 很适合这里:

rows.each(function(row) {
    var rowElems = row.all('td').map(function (td) {
        return td.getText();
    });

    // resolve the promise to see the output on the console
    rowElems.then(function (values) {
        console.log(values);
    });
});