我无法在量角器中打印 element.all 语句中的项目

I cannot print the items from element.all statement in protractor

我正在使用 element.all,我希望能够实际使用 console.log 来打印项目文本和计数。但出于某种原因我不能。 expect() 工作正常,但为什么我不能将计数转换为我可以使用的东西?

即:

this.dropdownText = function(locator) { 
    return $$(locator).then ( function(elems) {
        console.log( elems.count() ); //does not print whats expected....
        console.log( elems[0] ); //does not print out the first element
});

我想知道,因为我想在循环中使用下拉列表 COUNT。为什么我不能打印这些东西?有办法吗?

试试这个:

  this.dropdownText = function(locator) { 
        $$(locator).then(function(elems) {
            console.log(elems.count()); 
            elems[0].getText().then(function(elem){
                console.log(elem);
            });
        });
    });