how to send var to function of thenOpen function...

7 views
Skip to first unread message

bruce

unread,
Jun 13, 2017, 1:25:08 PM6/13/17
to casp...@googlegroups.com
Hey/Hi.

Testing out some very simple casperjs/phantomjs.

I basically, get a list of urls ,and do a simple fetch.. nothing complex.

However, in my test, once I get the url/content, I then invoke a
function "processPage" in this case, and I'd like to pass a variable
to it!! Should be quite simple, but I haven't run across how to do it.
Also need to know the child syntax for the "processPage" function..

Any examples/pointers/comments would be helpful.

Thanks much!

-------------------------

var processPage = function() { <<<<<
this.echo(this.page.content);
this.echo("bbbbbbb");
};


t=0;
//--test loop iteration
casper.then(function() {
// loop on array
casper.each(links, function(casper,link) {
t++;
dd=id[t];

casper.echo(link);
casper.echo("as");
//exit();

//casper.thenOpen(url1).waitForSelector(x("//a[contains(@href,
'securex')]"), processPage, <<<
casper.thenOpen(link).waitForSelector(x("//a[contains(@href,
'securex')]"), processPage,

function fail() {
console.log("oops11");
}
);
//--for the "this.thenOpen"
//casper.exit();
//this.exit();
//exit();

//casper.exit();
Reply all
Reply to author
Forward
0 new messages