Set Screen Size In Phantomjs/casperjs
I'm automating access to a web site to collect data from it. Unfortunately that page detects the screen size and doesn't give me the desired page if the screen is too small. When r
Solution 1:
According official documentation you can do it using viewportSize option.
varcasper=require("casper").create({//otheroptionshereviewportSize: {
width:1920,
height:1080
}
});
It will be more lightweight solution than overriding viewport size after each page loading.
Solution 2:
Here's how it works with CasperJS:
// at the start of the script filevar casper = require("casper").create({
// other options hereonPageInitialized: function (page) {
page.evaluate(function () {
window.screen = {
width: 1920,
height: 1080
};
});
}
});
// script goes on here
Solution 3:
Another option like you can see here:
casper.options.viewportSize = {width: 1600, height: 950};
Solution 4:
You can set by this as well while defining functions:
casper.viewport(1300, 1000).then(function () {
test.assertUrlMatches(/testing\.html$/);
});
Post a Comment for "Set Screen Size In Phantomjs/casperjs"