Spec-Zone.ru › Playwright

WebError

WebError class represents an unhandled exception thrown in the page. It is dispatched via the browserContext.on('weberror') event.

// Log all uncaught errors to the terminal
context.on('weberror', webError => {
  console.log(`Uncaught exception: "${webError.error()}"`);
});

// Navigate to a page with an exception.
await page.goto('data:text/html,<script>throw new Error("Test")</script>');

Methods​

error​

Unhandled error that was thrown.

Usage

webError.error();

Returns

  • Error

location​

Usage

webError.location();

Returns

  • Object
    • url string

      URL of the resource.

    • line number

      0-based line number in the resource.

    • column number

      0-based column number in the resource.

page​

The page that produced this unhandled exception, if any.

Usage

webError.page();

Returns

  • null | Page

© 2026 Microsoft
Licensed under the Apache License, Version 2.0.
https://playwright.dev/docs/api/class-weberror

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API