Home > Software engineering >  How to wait for element not present using Playwright
How to wait for element not present using Playwright

Time:07-15

I need to translate Selenium code into Playwright.

code:

self.wait_for_element_not_present("element CSS here")

Is the solution:

Not self.page.locator("element CSS here").is_visible()

CodePudding user response:

You can use the not_be_visible expect assertion for this.

expect('element CSS here').not_to_be_visible()

By default expect assertions have a 5 second timeout, in case you want to increase the timeout, you can do like this:

expect('element CSS here').not_to_be_visible(timeout=7000)
  • Related