Skip to content
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] How to wait until all matching elements disappear #11988

Closed
hornta opened this issue Feb 9, 2022 · 2 comments
Closed

[Question] How to wait until all matching elements disappear #11988

hornta opened this issue Feb 9, 2022 · 2 comments

Comments

@hornta
Copy link

hornta commented Feb 9, 2022

I need to wait until all elements for a matching locator disappears. Is this possible?

const locator = page.locator("input");
await locator.count(); // 12
// wait until there are no <input>
await locator.count(); // 0

EDIT:
I solved it by doing this but it feels quite hacky and ugly. Also I would need some timeout so it doesn't end up in an infinite loop? Is there a nicer way?

while(await spinners.count() > 0) {}
@pavelfeldman
Copy link
Member

This will wait:

await expect(locator).toHaveCount(0);

@pavelfeldman
Copy link
Member

Closing this as resolved, check out more assertions here: https://playwright.dev/docs/test-assertions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants