Casperjs Demo Login-Driving School Login

Source: Internet
Author: User

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 () &nbsp {          this.echo ("I ' ve waited for 5  Seconds again ");      });   });  //login page 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 ");      });   });  // According to the input verification code to the Code.txt file and read the 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 ': ' ID number ', ' passwd ': ' Password ', ' 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 "))  { &nbsP;  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 ();


This article is from the "Yan" blog, please be sure to keep this source http://suyanzhu.blog.51cto.com/8050189/1900433

Casperjs Demo Login-Driving School Login

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.