The below code throws the error NotConnectedError: Element is not attached to the DOM
on the second iteration, in case I have two todos. However, the todo.innerText()
is printed in the second loop before it throws the error. How could this be possible? And is there a way to work around that? It is possible the below method is a bad idea altogether to clean out a list of todos.
const todos = await page.$$('#todos-list tbody tr');
for await (const todo of todos) {
console.log(await todo.innerText());
await todo.click();
await page.click('#remove-todo-button');
}
This question might be because of tiredness as I've been hammering away with Playwright all day and night now. It's possible some sleep will alleviate this problem.