I'm having some trouble with accessing the DOM node of the nth items accessed from Selector in 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
}`
It is strange, it should work. Try this solution:
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With