click and clickLabel function no working by CasperJS -
i try data website http://www.bestbuy.com/site/dji-phantom-3-standard-quadcopter-white/4406800.p?skuid=4406800 using casperjs.
my situation have click button ratings & reviews
data show out.
but check out screen shot this.capture('check2.png);
after this.click('#reviews-accordion.accordion-wrapper');
looks button never been clicked , cause can't data rating , date
i have try selector , still doesn't work.
casper.then(function () { this.click('.accordion-toggle.accordion-item'); console.log('clicked reviews tab'); }); casper.then(function() { this.clicklabel('ratings & reviews', 'button'); console.log('clicked clicklabel'); });
how let click function work , appreciated.
thanks in advance.
here code:
var casper = require("casper").create({ verbose: true, timeout: 10000, loglevel: 'debug', // debug, info, warning, error pagesettings: { loadimages: false, loadplugins: false } }); var url = 'http://www.bestbuy.com/site/dji-phantom-3-standard-quadcopter-white/4406800.p?skuid=4406800'; var ratings = []; var dates = []; function getratings() { var ratings = document.queryselectorall('.bvrrratingnormalimage img'); return array.prototype.map.call(ratings, function (e) { return e.getattribute('title'); }); }; function getdates() { var dates = document.queryselectorall('span.bvrrvalue.bvrrreviewdate'); return array.prototype.map.call(dates, function (e) { return e.innertext; }); }; casper.start(url, function () { this.echo(this.gettitle()); }); casper.wait(2000, function () { this.echo('i have waited second.'); }); // here click function casper.then(function () { this.click('#reviews-accordion.accordion-wrapper'); console.log('clicked reviews tab'); }); // wait 2 seconds capture casper.wait(2000, function () { console.log('capturing...'); this.capture('check2.png'); }); casper.waitforselector('.bvrrreviewdisplaystyle5', function () { console.log('ratings loaded...'); }, function() { console.log('no exist'); }); casper.then(function () { ratings = this.evaluate(getratings); dates = this.evaluate(getdates); }); casper.then(function () { console.log('what going on'); this.echo(ratings.length + 'ratings found:'); this.echo('-' + ratings.join('\n -')); this.echo('-' + dates.join('\n -')); }); casper.run();
Comments
Post a Comment