Search code examples
pythonplaywright

How to expect attribute value with timeout using Playwright


This is my code:

expect(self.page.wait_for_selector(CSS_OF_ELEMENT, timeout=5000))\
    .to_have_attribute('aria-disabled', value)

My goal is to wait for an element with a given timeout, and search for the value of the attribute 'aria-disabled'.

The code doesn't compile. I get this error:

{ValueError}Unsupported type: <class 'playwright.sync_api._generated.ElementHandle'>

How do I fix my code?


Solution

  • You can do like this:

    expect("SELECTOR").to_have_attribute("aria-disabled", "value", timeout=5000)