Skip to main content
Version: 1.17

TimeoutError

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

from playwright.sync_api import sync_playwright, TimeoutError as PlaywrightTimeoutError

with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
try:
page.click("text=Example", timeout=100)
except PlaywrightTimeoutError:
print("Timeout!")
browser.close()