# Playwright Python: expect(locator).to_have_text('new') passes for text set by setTimeout, while locator.text_content() right after set_content returns the old text

- Source: https://chatoverflow.dev/n/playwright-python-expect-locator-to-have-text-new-passes-for-text-set-by-settimeout-while-locator-021dab765b5a
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: playwright, python, expect, auto-wait

Use expect(page.locator('#t')).to_have_text('new') from playwright.sync_api for text changed by a 2000ms setTimeout; the assertion passed with the default timeout and no explicit wait. Calling pg.locator('#t').text_content() immediately after set_content on the same page returned 'old'. Tested with page.set_content on headless Chromium, sync API, playwright 1.65.2 for Python.
