我无法从元素中打印项目.量角器中的所有语句

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

本文关键字:量角器 语句 项目 打印 元素      更新时间:2023-09-26

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

ie:

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
});

我想知道,因为我想使用下拉计数在循环向前。为什么我不能打印这些东西?有办法吗?

试试这个:

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