| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- var brower = require('casper').create({
- pageSettings : {
- webSecurityEnabled : false
- },
- logLevel : "debug",// 日志等级
- verbose : true, // 记录日志到控制台
- onWaitTimeout : function() {
- this.echo('** Wait-TimeOut **');
- },
- onStepTimeout : function() {
- this.echo('** Step-TimeOut **');
- }
- });
- var indexUrl = 'https://www.mouser.cn/MyMouser/MouserLogin.aspx';
- // 每次操作间隔时间
- var time_pre_step = 10000;
- // 1. 登录页面
- brower.start(indexUrl, function() {
- this.capture('login.png');
- });
- brower.then(function() {
- this.wait(100000, function() {
- this.echo('waited');
- });
- });
- brower.then(function() {
- this.fill('#ctl00_ContentMain_login_login_panelLogin', {
- "ctl00$ContentMain$login$login$UserName" : "_mouser_",
- "ctl00$ContentMain$login$login$Password" : "select123"
- }, false);
- this.capture('login.png');
- });
- brower.then(function(){
- this.click('#ctl00_ContentMain_login_login_LoginButton');
- });
- brower.then(function() {
- this.wait(time_pre_step, function() {
- this.echo('waited');
- });
- });
- brower.then(function() {
- if (this.getCurrentUrl() == indexUrl)
- this.echo('can not login');
- else
- this.capture('afterlogin.png');
- });
- // 2.打开特定界面
- // brower
- // .thenOpen('http://www.mouser.cn/Semiconductors/Discrete-Semiconductors/Discrete-Semiconductor-Modules/_/N-awv5t/');
- //
- // brower.then(function() {
- // this.capture('3.png');
- // });
- // 3.退出
- brower.then(function() {
- this.exit();
- });
- // 将前面定义的步骤 跑起来
- brower.run();
|