File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import os
44from contextlib import AsyncExitStack
5+ from logging import getLogger
56from types import TracebackType
67from typing import TYPE_CHECKING , Any
78
1415if TYPE_CHECKING :
1516 import pytest
1617
18+ _logger = getLogger (__name__ )
19+
1720
1821class DisplayFixture :
1922 """A fixture for running web-based tests using ``playwright``"""
@@ -77,12 +80,16 @@ async def configure_page(self) -> None:
7780 self .page .set_default_timeout (self .timeout * 1000 )
7881 self .page .on (
7982 "requestfailed" ,
80- lambda x : print (f"BROWSER LOAD ERROR: { x .url } \n { x .failure } " ), # noqa: T201
83+ lambda x : _logger .error (f"BROWSER LOAD ERROR: { x .url } \n { x .failure } " ),
84+ )
85+ self .page .on (
86+ "console" , lambda x : _logger .info (f"BROWSER CONSOLE: { x .text } " )
8187 )
82- self .page .on ("console" , lambda x : print (f"BROWSER CONSOLE: { x .text } " )) # noqa: T201
8388 self .page .on (
8489 "pageerror" ,
85- lambda x : print (f"BROWSER ERROR: { x .name } - { x .message } \n { x .stack } " ), # noqa: T201
90+ lambda x : _logger .error (
91+ f"BROWSER ERROR: { x .name } - { x .message } \n { x .stack } "
92+ ),
8693 )
8794
8895 async def __aexit__ (
You can’t perform that action at this time.
0 commit comments