hubcap viewport

Set the browser viewport size.

When to use

Set the browser viewport to specific width and height in pixels. Use emulate for full device emulation including user agent and device pixel ratio.

Usage

hubcap viewport <width> <height>

Arguments

ArgumentTypeRequiredDescription
widthintYesViewport width in pixels
heightintYesViewport height in pixels

Flags

None.

Output

FieldTypeDescription
widthnumberThe viewport width that was set
heightnumberThe viewport height that was set
{"width":1920,"height":1080}

Errors

ConditionExit codeStderr
Invalid width (non-numeric)1invalid width: <value>
Invalid height (non-numeric)1invalid height: <value>
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Set a 1080p viewport:

hubcap viewport 1920 1080

Set a mobile-sized viewport:

hubcap viewport 375 667

Set a viewport size and then take a screenshot at that resolution:

hubcap viewport 1440 900 && hubcap screenshot desktop.png

See also

  • emulate - Emulate a full device profile with viewport, user agent, and touch
  • screenshot - Take a screenshot of the page
  • pdf - Generate a PDF of the page