Reputation: 1969
I can set the viewportSize to get small mobile layout & sized screenshots:
// 1080 x 1920 is Nexus 5 resolution
casper.options.viewportSize = {width: 1080 / 3, height: 1920 / 3};
However the DPI is low, unlike when viewed on mobile.
My page uses the viewport meta tag to control layout on mobile browsers like so
<meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
Upvotes: 1
Views: 367
Reputation: 1969
What we really need is to set the Device Pixel Ratio. It appears as of July 2016, PhantomJS is lacking that ability, however people are working on it.
Upvotes: 1
Reputation: 1969
Keep full resolution, and use Casper's zoom
// 1080 x 1920 is Nexus 5 resolution
casper.options.viewportSize = {width: 1080, height: 1920};
casper.start().zoom(3)
This will probably fail under responsive designs with @media queries relative to screen size. I'm still hoping for a less hackish answer, but this at least gets us a little closer.
Upvotes: 0