Noneme
Noneme

Reputation: 23

How can I change the screen resolution of PhantomJS?

In any way I can not find a question concerning change of the sanction of the screen. There will always be 1024x768. Changing the viewportSize does not change the screen resolution, by itself. I checked the resolution here: link

This is for node:

var WebPage = require('webpage');
page = WebPage.create()

page.onInitialized = function () {
    page.evaluate(function () {
        window.screen = {width: 1600, height: 900, availWidth: 1600, availHeight: 900};
    });
};

page.open('http://browserspy.dk/screen.php');
page.onLoadFinished = function () {
    page.render('ScreenShot' + '.png');
    phantom.exit();
}

Can anyone remake for the python?

Upvotes: 1

Views: 1036

Answers (1)

Ankur
Ankur

Reputation: 1086

Try using viewportSize. Refer this link ViewPortSize

var webPage = require('webpage');
var page = webPage.create();

page.viewportSize = {
  width: 480,
  height: 800
};

Upvotes: 1

Related Questions