javascript - CasperJS viewport & viewportSize not resizing browser -
is having issues lately casperjs or phantomjs viewport
or viewportsize
?
i've tried using
page.viewportsize = {width: 1280, height: 1024}; casper.start() .viewport(800, 600); casper.options.viewportsize = {width: 1290, height: 1024};
no matter put them in code browser size still stays default 300, 400.
/*jshint strict:false*/ /*global caspererror, console, phantom, require*/ var links = []; var casper = require("casper").create(); var w = window.innerwidth; var h = window.innerheight; function getlinks() { var links = document.queryselectorall("h3.r a"); return array.prototype.map.call(links, function(e) { try { // google handles redirects hrefs script of theirs return (/url\?q=(.*)&sa=u/).exec(e.getattribute("href"))[1]; } catch (err) { return e.getattribute("href"); } }); } casper.options.viewportsize = {width: 1600, height: 950}; casper.start("http://google.fr/", function() { // search 'casperjs' google form this.viewport(900, 800); this.fill('form[action="/search"]', { q: "casperjs" }, true); }); casper.then(function() { // aggregate results 'casperjs' search links = this.evaluate(getlinks); // search 'phantomjs' fillin form again this.fill('form[action="/search"]', { q: "phantomjs" }, true); }); casper.then(function() { // aggregate results 'phantomjs' search links = links.concat(this.evaluate(getlinks)); }); console.log("height==> " + h); console.log("width==> " + w); casper.run(function() { // echo results in pretty fashion this.echo(links.length + " links found:"); this.echo(" - " + links.join("\n - ")); this.exit(); });
Comments
Post a Comment