var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
pageSettings: {
loadImages: false,
loadPlugins: true,
userAgent: 'Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0'
}
});
//phantom.outputEncoding="gbk";
casper.options.viewportSize = {width: 1680, height: 924};
casper.start('http://bulo.hujiang.com/app/login?source=nbulo&returnurl=/home/');
casper.waitForSelector("form#myform input[name='txtUsername']",
function success() {
this.test.assertExists("form input[name='txtUsername']");
this.fill("form",{
'txtUsername':'shixiaobao17',
'txtPassword':'×××××your password*****'
},false);
this.click("input#btnLogin");
},
function fail() {
this.test.assertExists("form input[name='txtUsername']");
}); casper.waitFor(function check() {
return this.getCurrentUrl().indexOf("bulo.hujiang.com/home")>-1;
}, function then() {
console.log("登录成功!!!!!!!!!!!!");
}).then(function(){
console.log("执行登录后的其它操作!!!!!!!!!!!!");
if(this.exists("#btn_card_do")){
this.click("#btn_card_do");
this.waitForSelector("#my_hb_btn",function success(){
console.log("打卡成功!");
},function fail(){
console.log("打卡失败!");
});
}else{
console.log("今天已经打过卡啦!");
} });
casper.run(function() {this.test.renderResults(true);});

相关资料:http://casperjs.readthedocs.org/en/latest/modules/casper.html

最新文章

  1. 认识AMD、CMD、UMD、CommonJS
  2. 耿丹CS16-2班第一次作业汇总
  3. My Tornado Particle Effect
  4. [GeekBand] STL与泛型编程(2)
  5. opengl (1) 基本API的熟悉
  6. 20169210《Linux内核原理与分析》第四周作业
  7. inner join跟where查询的区别
  8. 杂项(最小表示法):HZOI 2015 Glass Beads
  9. 蓝牙4.0BLE cc2540 usb-dongle的 SmartRF Packet Sniffer 抓取数据方法
  10. [Javascript] JSON.parse API
  11. spring、spring mvc、mybatis框架整合基本知识
  12. js实现分页
  13. Linux之旅-ubuntu下搭建nodejs环境
  14. 关于:未能加载文件或程序集“ICSharpCode.SharpZipLib”或它的某一个依赖项异常的解决方案
  15. RecyclerView联动滑动失败
  16. RocketMQ事务消息-demo
  17. iOS8中 UILocalNotification 和 UIRemoteNotification 使用注意
  18. canvas学习之折线图
  19. 从概率图模型pgm到rbm
  20. 2.BIND服务基础及域主服务器配置

热门文章

  1. go get 升级所有
  2. SpringBoot整合Thymeleaf
  3. Java8新特性Lambda表达式
  4. java在线聊天项目 swt可视化窗口Design 好友列表窗口
  5. iOS开源库
  6. vue axios 请求本地接口端口不一致出现跨域设置代理
  7. NOIp2018心得
  8. (22)zabbix触发器依赖关系详解
  9. (2)zabbix硬件需求
  10. python插件,pycharm基本用法,markdown文本编写,jupyter notebook的基本操作汇总