element.all始终返回count为0



我正试图使用量角器测试一个动态web表,并试图找到标题、行和列的计数,但总是得到0作为计数var x=element.all(通过.xpath('//table//thead//tr//th'(

x.count((.然后(函数(c({

console.log(c(;

});

我也尝试过使用element.all(by.css(,但它返回的结果相同,有人能帮忙吗?我使用了selenium并能够检索值,所以xpath没有错,但我必须使用量角器来获取相同的值。正在运行的Selenium脚本List col=driver.findElements(By.xpath("//div[@class='table-wrapper']//table//thead//tr/th"(;System.out.println(col.size(((;

html

尝试以下代码

var x = await element.all(by.css('table[title="status"]'))
//Add wait if the table take more time to load
x.count().then(function(c){
console.log(c);
});

通常,您应该避免使用xpath,因为它的效率非常低。

这应该对你有用:

var table = element(by.css('table.table'));
table
.element(by.css('thead'))
.all(by.css('tr th'))
.count()
.then(function(count) {
console.log('count:',count);
});

最新更新