Skip to main content
Version: 1.16

TimeoutError

TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. page.wait_for_selector(selector, **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()