Skip to content

[BUG] Not able to capture JS error on Playwright Page #16648

@ghost

Description

Context:

  • Playwright Version: 1.13.0
  • Operating System: Windows
  • Browser: [All, Chromium, Firefox, WebKit]
  • Language: C#

Code Snippet

I am trying to capture JS error on Playwright Page using window.onerror event,
but window.onerror event is not firing during these JS errors.

Does window.onerror event fires automatically if JS errors occur on a playwright page
For example: Pseudo code

window.onerror = function () {
    console.log("JS errors captured");
}

str=""; //str is a Javascript with error
try{
  PlaywrightPage.EvaluateAsync(str);
}
catch
{
  Console.writeLine("Exception occurred");
}

Expected Outcome:
JS errors captured
Exception Occurred

Actual Outcome:
Exception Occurred

Follow up Question
What are other ways to capture JS errors if we open a page on browser launched using Playwright? (Other than window.onerror() )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions