使用 `element.all(by.id())` 获取元素数量
Getting number of elements by using `element.all(by.id())`
我想做这样的事情:
it('should get number of API Key list'), () => {
let numApiKeys = 0;
element.all(by.id('ApiKeyList')).count().then(function(count) {
numApiKeys = count; // suppose count = 5
});
console.log(numApiKeys); // but it shows numApiKeys = 0
});
我无法获取 'ApiKeyList' 的长度; numApiKeys
总是显示 0
.
如何获得列表的实际长度?
尝试以下操作:
let listCount = await element.all(by.id('radioApiKeyList')).count();
console.log(listCount);
正如 Joaquin Casco 提到的,以下代码有效:
it('should get number of API Key list'), async () => {
// suppose ApiKeyList have length of 5
let numApiKeys = await element.all(by.id('ApiKeyList')).count();
console.log('numApiKeys = ' + numApiKeys); // numApiKeys = 5
});
我想做这样的事情:
it('should get number of API Key list'), () => {
let numApiKeys = 0;
element.all(by.id('ApiKeyList')).count().then(function(count) {
numApiKeys = count; // suppose count = 5
});
console.log(numApiKeys); // but it shows numApiKeys = 0
});
我无法获取 'ApiKeyList' 的长度; numApiKeys
总是显示 0
.
如何获得列表的实际长度?
尝试以下操作:
let listCount = await element.all(by.id('radioApiKeyList')).count();
console.log(listCount);
正如 Joaquin Casco 提到的,以下代码有效:
it('should get number of API Key list'), async () => {
// suppose ApiKeyList have length of 5
let numApiKeys = await element.all(by.id('ApiKeyList')).count();
console.log('numApiKeys = ' + numApiKeys); // numApiKeys = 5
});