如何捕获所有控制台错误日志剧作家
我尝试了所有这些,
page.on("console", lambda msg: print(f"error: {msg.text}") if msg.type == "error" else None)
page.on("console", lambda msg: print(msg.text))
page.on("pageerror", lambda exc: print(f"uncaught exception: {exc}"))
没有任何效果
终端输出
python main.py
/home/xxx/.local/lib/python3.9/site-packages/trio/_core/_multierror.py:511: RuntimeWarning: You seem to already have a custom sys.excepthook handler installed. I'll skip installing Trio's custom handler, but this means MultiErrors will not show full tracebacks.
warnings.warn(
I tried all of this,
page.on("console", lambda msg: print(f"error: {msg.text}") if msg.type == "error" else None)
page.on("console", lambda msg: print(msg.text))
page.on("pageerror", lambda exc: print(f"uncaught exception: {exc}"))
Nothing works
Terminal output
python main.py
/home/xxx/.local/lib/python3.9/site-packages/trio/_core/_multierror.py:511: RuntimeWarning: You seem to already have a custom sys.excepthook handler installed. I'll skip installing Trio's custom handler, but this means MultiErrors will not show full tracebacks.
warnings.warn(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在没有最低限度可重现的示例的情况下,使用示例场景代码来说明用法:
参考: https://playwright.dev/python/docs/api/class-consolemessage
In the absence of a minimally reproducible example , a sample scenario code to illustrate the usage:
Reference: https://playwright.dev/python/docs/api/class-consolemessage