我尝试向网站发送输入,但也让用户确认是否要从控制台继续,然后在确认后继续。但是,我遇到了点击功能的问题。
casper.then(function(){
this.click('#ctl00_ContentPlaceHolder1_btnAllSvr');
});
工作但......
casper.then(function(){
var confirmation = system.stdin.readLine();
if(confirmation == 'y'){
this.click('#ctl00_ContentPlaceHolder1_btnAllSvr');
this.capture('test7.png');
this.echo('success');
}
this.exit();
});
这不是。感觉好像除了click函数之外的任何东西都在casper.then()中使用它根本没有正确触发。
var system = require('system');
var utils = require('utils');
var casper = require('casper').selectXPath;
var casper = require('casper').create({
verbose: false,
logLevel: 'debug'
});
casper.start();
casper.thenOpen('https://someurl.com', function(){
});
casper.then(function(){
this.click('#button1');
});
casper.then(function(){
lastname = casper.evaluate(function () {
return __utils__.getElementByXPath('//form[@id=\'aspnetForm\']//tbody/tr[2]/td[4]').innerHTML;
});
system.stdout.write('\nReset password for this user? Y/N \n');
var confirmation = system.stdin.readLine();
if(confirmation == 'y'){
this.click('#ctl00_ContentPlaceHolder1_btnSAllSvr');
this.echo('success');
}
this.exit();
});