How to expect attribute value with timeout using Playwright

Question:

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 to fix my code?

Asked By: Tal Angel

||

Answers:

You can do like this:

expect("SELECTOR").to_have_attribute("aria-disabled", "value", timeout=5000)
Answered By: Alapan Das
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.