📄 playwright-python/python/docs/api/class-timeouterror

File: class-timeouterror.md | Updated: 11/18/2025

Source: https://playwright.dev/python/docs/api/class-timeouterror

Skip to main content

TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. locator.wait_for() or browser_type.launch() .

  • Sync

  • Async

    from playwright.sync_api import sync_playwright, TimeoutError as PlaywrightTimeoutErrorwith sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page() try: page.locator("text=Example").click(timeout=100) except PlaywrightTimeoutError: print("Timeout!") browser.close()

    import asynciofrom playwright.async_api import async_playwright, TimeoutError as PlaywrightTimeoutError, Playwrightasync def run(playwright: Playwright): browser = await playwright.chromium.launch() page = await browser.new_page() try: await page.locator("text=Example").click(timeout=100) except PlaywrightTimeoutError: print("Timeout!") await browser.close()async def main(): async with async_playwright() as playwright: await run(playwright)asyncio.run(main())