无法在testcafe中使用循环检索值



错误:i未定义。

无法通过在testcafe中使用for循环来检索值,因为未定义"i"而引发错误。

this.totalaab=选择器(((=>document.querySelectorAll('aab-product-tile'((;

async verifyvale() {
const accountcount = await this.totalaab.count;
console.log(accountcount)
for (let i = 0; i < accountcount; i++) {
console.log(i);
console.log(await Selector(() => document.querySelectorAll('aab-product-tile')));
let overviewvalue = Selector(() => document.querySelectorAll('aab-product-tile')[i].shadowRoot.querySelector('.m-0.overflow-ellipsis.title-label.text-truncate.text-green.font-weight-500'));
console.log(await overviewvalue.innerText);
//await t.expect(await overviewvalue(i).exists).ok();
}
}

不建议在Selector函数中使用i变量。如果要按索引查询元素,可以使用Selector.nth method中描述的nth方法。

最新更新