1

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.

Related info

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">
Anthony Astige
  • 1,919
  • 1
  • 13
  • 18

2 Answers2

1

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.

Anthony Astige
  • 1,919
  • 1
  • 13
  • 18
0

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.

Anthony Astige
  • 1,919
  • 1
  • 13
  • 18