WebError
WebError 類別代表在頁面中拋出的未處理異常。它通過 browser_context.on("weberror") 事件分派。
- 同步
- 異步
# Log all uncaught errors to the terminal
context.on("weberror", lambda web_error: print(f"uncaught exception: {web_error.error}"))
# Navigate to a page with an exception.
page.goto("data:text/html,<script>throw new Error('test')</script>")
# Log all uncaught errors to the terminal
context.on("weberror", lambda web_error: print(f"uncaught exception: {web_error.error}"))
# Navigate to a page with an exception.
await page.goto("data:text/html,<script>throw new Error('test')</script>")
屬性
error
新增於:v1.38拋出的未處理錯誤。
用法
web_error.error
返回
page
新增於:v1.38產生此未處理異常的頁面(如果有的話)。
用法
web_error.page
返回