hello I am new to Casper and node
I am trying to run a code that scrpping data from a site
but WaitForselector function is not working correctly .
my code is
casper.waitForSelector('.searchAutoSuggstn', function() {
this.echo('Search auto suggestion.'); // this line is printing my console
var data = this.evaluate(function() {
var suggestions = [];
this.echo('Search auto suggestion data.'); //But this line is not printing my console
var element = $('.searchAutoSuggstn .suggestionsList_menu').find('.topProdhead_left').prevAll().filter(function() {
this.echo('omnitrack');
return $(this).data("omnitrack") ;
});
is any boddy can tell me whats the main problem ?
You can't call casper methods such as casper.echo() in casper.evaluate() since evaluate executes code in the context of the browser.
You could use console.log in the browser to output to the javascript console which you can then catch with the hook
casper.on("remote.messsage", function(msg){
// Do something
});