playwright.expect.expect_to_change
playwright.expect.expect_to_change(func, timeout_secs=10)
Context manager that yields when the value returned by func() changes.
Use this around code that has a side-effect of changing some state asynchronously (such as all browser actions), to prevent moving onto the next step of the test until this one has actually taken effect.
Parameters
Raises
Type | Description |
---|---|
TimeoutError | If the value does not change within timeout_secs. |
Example
with expect_to_change(lambda: page.locator("#name").value()):
page.keyboard.send_keys("hello")