casperjs類比登入-駕校登入

來源:互聯網
上載者:User

標籤:類比   casperjs   登入   

var casper = require(‘casper‘).create({clientScripts:["jquery.js"],pageSettings:{// userAgent: ‘Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; Tablet PC 2.0; .NET4.0E)‘userAgent:‘Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)‘}});var fs = require(‘fs‘);var code;casper.start(‘http://www.jsjtxx.com/spage/Beginner-Login.html‘);casper.then(function() {      this.wait(5000,function() {          this.echo("I‘ve waited for 5 seconds again");     });  }); //登入頁面casper.then(function(){if (this.exists("#ttt")) {this.capture("code.jpeg"); };});casper.then(function() {    this.wait(30000,function() {          this.echo("I‘ve waited for 30 seconds again ,please input code");     });  }); //根據輸入驗證碼到code.txt檔案並讀取casper.then(function(){if (fs.exists("code.jpeg") && fs.exists("code.txt")) {code = fs.read("code.txt");}});casper.then(function() {      this.wait(5000,function() {          this.echo("I‘ve waited for 5 seconds again ,please input code");     });  }); casper.then(function(){this.fill(‘form[id="fmLogin"]‘,{‘deptId‘:‘320300‘,‘loginId‘:‘社會安全號碼‘,‘passwd‘:‘密碼‘,‘authCode‘:code},false);});casper.then(function(){this.click(".login_buton");this.capture("login.jpeg"); });casper.then(function() {      this.wait(10000,function() {          this.echo("I‘ve waited for 10 seconds again");     });  });casper.then(function() {      this.echo(‘new location is ‘ + this.getCurrentUrl());      this.capture("main.jpeg");  });casper.then(function() {      if (this.exists("#plan")) {    if (this.exists("#studyForm1 .btn_iskt2 span")) {    this.click("#studyForm1 .btn_iskt2 span");    this.echo("exists");    }else{    this.echo("not exists");    }    }else{    this.echo("not exists");    }});casper.then(function() {      this.wait(10000,function() {          this.echo("I‘ve waited for 10 seconds again");     });  });casper.then(function() {      this.capture("video.jpeg");   });casper.run();


本文出自 “素顏” 部落格,請務必保留此出處http://suyanzhu.blog.51cto.com/8050189/1900433

casperjs類比登入-駕校登入

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.