-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Iteration over a table's <tr> tags to click and remove them #2034
Comments
When you click For react pages, you should not store stale state, you should query all items and click |
@pavelfeldman This is not a React page, but it is as you say very likely it is re-built. What happens is that an API call is made when clicking One thing I tried was the new A second option is to on the first iteration actually get numb of elements, click remove, and poll for But I find neither of them appealing. |
was this resolved ? I'm dealing with the exact same problem as @thernstig and it's not a react page ... how to solve this ? Edit : One workaround is iterating directly through the childs of the element without creating the todos const list , because mostly they have similaire xpath that will allow you to loop through them . That solved things for me in many other examples |
This is what worked for me: async function removePills(pills: Locator) {
const pillButtons = await pills.all();
if (pillButtons.length > 0) {
await pillButtons[0].click();
await removePills(pills);
}
}
await removePills(
this.iframe.getByTestId("pw-provider-pill").getByRole("button")
); A loop will not work unfortunately since Playwright internally uses nth(0), nth(1)... to click elements. And if the button deletes the element at nth(0) then nth(1), if there are two elements, will not be there |
@jkohlin could you re-write a new issue? Considering this was closed. You can then reference this, and add the information you have regarding the loop behavior you found. |
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, thetodo.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.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.
The text was updated successfully, but these errors were encountered: