Skip to content

Commit 5993ffc

Browse files
committed
Better playwright logging
1 parent 111a841 commit 5993ffc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/test_app/tests/utils.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,16 @@ def start_playwright_client(cls):
117117
cls.browser = cls.playwright.chromium.launch(headless=bool(headless))
118118
cls.page = cls.browser.new_page()
119119
cls.page.set_default_timeout(10000)
120-
cls.page.on("console", lambda msg: _logger.error("error: %s", msg.text) if msg.type == "error" else None)
120+
cls.page.on("console", cls.playwright_logging)
121+
122+
@staticmethod
123+
def playwright_logging(msg):
124+
if msg.type == "error":
125+
_logger.error(msg.text)
126+
elif msg.type == "warning":
127+
_logger.warning(msg.text)
128+
elif msg.type == "info":
129+
_logger.info(msg.text)
121130

122131
@classmethod
123132
def shutdown_playwright_client(cls):

0 commit comments

Comments
 (0)