Playwright + Python · Lesson 24 of 37
Module 24: Browser Events
Your task
Implement capture_console_errors(page, error_list):
Write it in the editor, then press Check answer (Ctrl + Enter).
page.on("pageerror", lambda err: print(f"Frontend JS Exception: {err}"))
def on_console(msg):
if msg.type == "error":
print(f"Console error: {msg.text}")
page.on("console", on_console)Playwright allows you to listen to internal browser events in real time. In this lesson, you will capture console errors, unhandled JavaScript exceptions, and network traffic during test execution. Let's monitor browser events!
Part of the Playwright + Python course (Playwright with Python). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
Yes! Collecting console errors in a list and asserting len(errors) == 0 in teardown catches frontend regressions.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___