我遇到一些麻烦,访问来自DOM
在nth
访问的Selector
项目testCafe
节点:
var element = Selector('input');
console.log(element) //logs a function - too early
var elementTest = await element();
console.log(elementTest) // logs first DOM node
var elementsCount = await element.count; // logs 5
console.log(`Elements: ${elementsCount}`);
for(let i = 0; i < elementsCount; i++) {
const test = await element.nth(i);
console.log(`${i}: ${ test }`); // logs a function - too early
const sanity = await test(); // breaks the loop
}`
奇怪的是,它应该工作。尝试这种解决方案:
const elements = Selector('input');
var elementsCount = await elements.count;
for(let i = 0; i < elementsCount; i++) {
const elementSelector = elements.nth(i);
const sanity = await elementSelector();
}