这是我的代码。它运行正常,它访问网站,并填写zipcode确定。但我不知道为什么它不能点击按钮“GO”。我的代码有什么问题?谢谢
网站是:https://www.az.aaa.com/membership/gift-membership-form?promocode=zumz0
谢谢!
var casper = require("casper").create();
var mouse = require("mouse").create(casper);
var casper = require('casper').create({
verbose: true,
logLevel: 'debug', // debug, info, warning, error
clientScripts: ["includes/jquery.min.js"],
pageSettings:{
loadImages: true,
loadPlugins: false,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
}
}
);
var fs = require('fs');
//var password = casper.cli.get(1);
function strip_tags(str) {
str = str.toString();
return str.replace(/<\/?[^>]+>/gi, '');
}
casper.start().thenOpen("https://www.az.aaa.com/membership/gift-membership-form?promocode=zumz0", function(){
console.log("1. Access Site");
});
casper.waitForSelector('#edit-zipcode', function(){
console.log("2. Box Zipcode Found ! ");
this.capture('site_box_zipcode.png');
});
casper.then(function(){
fs.write("debug_zipcode.html", this.getPageContent(), 'w');
});
casper.then(function(){
console.log("3. Filling Form Zipcode")
this.evaluate(function(){
$('#edit-zipcode').attr('value', '86322');
$('#edit-tqs1-submit').click();
//document.getElementById("edit-zipcode").value='86322';
//document.getElementById("edit-tqs1-submit").click();
});
//this.mouse.rightclick('button.col-xs-12 col-md-1 product-button js-product-button pull-right');
})
//
casper.then(function(){
this.wait(7000);//Wait a bit so page loads (there are a lot of ajax calls and that is why we are waiting 6 seconds)
this.capture('Afterpostzipcode.png');
console.log("4. Finish Capture Picture");
});
casper.then(function(){
fs.write("debug_fl.html", this.get, 'w');
});
casper.run();