mercredi 21 janvier 2015

How to use jQuery find() function with CasperJS

I want to do something similar to Cabybara within function in casperJS.I want to get Parent_divs and retrieve text from its child elements.


Something like this:



$('div.education').find('h4').text
$('div.education').find('h1').text


Code snippet is as follows:



function get_details(){
casper.page.injectJs('/jquery-latest.min.js');
var links = casper.evaluate(function() {
var elements = $('div.education');
return elements.map(function(e){
this.fetchText(casper.evaluate(function(){
return e.find('h4.summary');
}));
this.fetchText(casper.evaluate(function(){
return e.find('h1');
}));

});
});
casper.echo(links);
};


Currently its returning null.How to achieve this in casperJS?


Aucun commentaire:

Enregistrer un commentaire