标签:blog http io os ar java for sp div
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
标签:blog http io os ar java for sp div
原文地址:http://www.cnblogs.com/jamesbd/p/3998031.html