WebError
WebError class represents an unhandled exception thrown in the page. It is dispatched via the browser_context.on("weberror") event.
- Sync
- Async
# 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>")
屬性 (Properties)
error
Added in: v1.38Unhandled error that was thrown.
使用方式
web_error.error
傳回值
page
Added in: v1.38The page that produced this unhandled exception, if any.
使用方式
web_error.page
傳回值