简体   繁体   English

CLI可以在phantomjs或无头铬中加载html并获取任何JavaScript错误

[英]CLI to load html in phantomjs or chromium headless and get any javascript errors

I have a self-contained non-interactive html artifact that I would like to check for javascript errors in an automated single CLI call way so it can integrate with my java based functional tests. 我有一个自包含的非交互式html工件,我想以自动化的单个CLI调用方式检查javascript错误,以便它可以与基于Java的功能测试集成。 I just want to send the html file to some headless browser and get any errors like would be in the F12 console. 我只想将html文件发送到一些无头浏览器,并得到类似F12控制台中的任何错误。 Preferably this does not involve a server. 优选地,这不涉及服务器。

PhantomJS has page.onError callback just for this purpose. PhantomJS为此有page.onError回调。 Just conjure up a script that collects errors and have it write errors to a log or send via email, then run the script from cli when needed. 只需构想一个收集错误的脚本,然后将其写入日志或通过电子邮件发送错误,然后在需要时从cli运行该脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM