bruce
unread,Jun 19, 2017, 11:48:56 AM6/19/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to casp...@googlegroups.com
Hi.
Got what should be a simple issue.
Casperjs + waitfor + post method!
The following chunk of code is illustrative of what I'm looking for.
The commented out GET works no prob.
However I'm not sure what the correct syntax for doing a waitfor+POST
should be. What I have doesn't appear to be working. It hangs. If
someone can verify that the syntax is wrong or correct, or point me to
any sample code/docs.
thanks
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
waitTimeout: 600000, // new maximum waitTimeout
pageSettings: {
loadImages: true,
javascriptEnabled: true,
}
});
phantom.timeout=600000;
phantom.stepTimeout=600000;
phantom.cookiesEnabled = true;
var x = require('casper').selectXPath;
var ua='Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0'
var url1 = casper.cli.get("url1");
var pdata = casper.cli.get("pdata");
casper.userAgent(ua);
//casper.start(u);
casper.start();
var processPage = function() {
this.echo(this.page.content).exit();
};
/*
***THIS WORKS FOR A BASIC GET/URL
casper.thenOpen(url1).waitForSelector(x("//a[contains(@href,
'securex')]"), processPage,
function fail() {
console.log("oops11");
}
);
*/
//-- appears to have issues with the post..
//-- how should the post syntax be implemented?????
//
casper.thenOpen(url1,{
method: 'post',
data: pdata
}).waitForSelector(x("//a[contains(@href, 'securex')]"), processPage,
function fail() {
console.log("oops11");
}
);