用casperjs检查网页中的js错误
来源:互联网 发布:媒体网络 编辑:程序博客网 时间:2024/06/05 20:50
https://coderwall.com/p/uzaaaw
I recently needed to make reorganize javascript files on a huge Rails app. I wanted to be sure that I had not broken javascript dependancies with the reorganization, so I needed to crawl the site for js errors each time I restructured the load strategy for js.
I ended up using CasperJs to accomplish this. It was pretty easy.
First install Casper
This is what my script ended up looking like
var casper = require('casper').create();var errors = [];// log into the site firstcasper.start('http://localhost:3000', function() { this.fill('form[action="/session"]', { 'login[email]': 'username', 'login[password]': 'password' }, true);});// add as many pages as you would like...casper.thenOpen('http:localhost:3000/accounts/1/products');casper.on("page.error", function(msg, trace) { this.echo("Error: " + msg, "ERROR"); this.echo("file: " + trace[0].file, "WARNING"); this.echo("line: " + trace[0].line, "WARNING"); this.echo("function: " + trace[0]["function"], "WARNING"); errors.push(msg);});casper.run(function() { if (errors.length > 0) { this.echo(errors.length + ' Javascript errors found', "WARNING"); } else { this.echo(errors.length + ' Javascript errors found', "INFO"); } casper.exit();});
Then run the script, in my case I called it "check_for_errors.js"
The script will output any errros found on the pages you hit.
- 用casperjs检查网页中的js错误
- 用casperjs截取任意网页区域
- 网页错误检查工具
- JS屏蔽网页中的错误提示信息
- js检查错误
- 检查网页代码的错误
- casperjs中的step
- phantomjs + casperjs 抓取网页截图
- 异步网页采集利器CasperJs
- [JS]网页登录检查、跳转系统
- casperjs
- Casperjs
- casperjs
- CasperJS
- CasperJs轻松web测试&模拟网页操作
- casperjs无法加载https的网页
- CasperJS needs PhantomJS v1.× 错误解决方法
- myeclipse中的js错误
- Android的传感器应用
- SQL 语句中按照in语句原有的顺序进行排序
- 好吧。
- iphone4/4s 程序适配 iphone5 过程 经验 全记录
- CGlib-打造无入侵的类代理[转载]
- 用casperjs检查网页中的js错误
- 名企献身说法:我们喜欢这样的简历
- (十七)迭代器模式详解(foreach的精髓)
- JavaSE 拾遗(12)——JavaSE IO...(3)
- Integer.parseInt(String s, int radix)方法介绍(修正版)
- SQL vs NoSQL:数据库并发写入性能比拼
- Django学习笔记-2-创建自己的项目
- 再论“Ansi,UTF8,Unicode,ASCII编码的区别”
- OpenStack Swift源码分析(5)----swift-ring-builder源代码解析之二