Skip to content

[Question] Iteration over a table's <tr> tags to click and remove them #2034

Closed

Description

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions