Reputation: 259
I am using PlayWright and want to perform an operation whilst an element is not found in the DOM.
My code looks similar to:
while(!page.locator('.list-empty'))
{
await removeAllRoles();
}
this doesnt work. How can i achieve this?
Upvotes: 2
Views: 3769
Reputation: 8662
You need to use isVisible
method for that.
while(!(await page.locator('.list-empty').isVisible())) {
// do something
}
Also, you can use isHidden
method. It's the opposite of isVisible
.
while(await page.locator('.list-empty').isHidden()) {
// do something
}
Upvotes: 1