hubcap emulate

Emulate a mobile device with viewport, user agent, and touch.

When to use

Emulate a mobile device with viewport, user agent, and touch capabilities. Use viewport to only change dimensions without setting user agent or touch. Use useragent to only change the user agent string.

Usage

hubcap emulate <device>

Arguments

ArgumentTypeRequiredDescription
devicestringYesDevice name to emulate (e.g., iPhone-12, Pixel-5, iPad-Pro)

Flags

None.

Output

FieldTypeDescription
devicestringThe device name that was emulated
widthnumberViewport width in pixels
heightnumberViewport height in pixels
deviceScaleFactornumberDevice pixel ratio
mobilebooleanWhether mobile mode is enabled
{"device":"iPhone 12","width":390,"height":844,"deviceScaleFactor":3,"mobile":true}

Errors

ConditionExit codeStderr
Unknown device name1error: unknown device: <name>
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Emulate an iPhone 12:

hubcap emulate "iPhone 12"

Emulate a Pixel 5:

hubcap emulate "Pixel 5"

Emulate a device, navigate to a page, and take a screenshot:

hubcap emulate "iPhone 12" && hubcap goto 'https://example.com' && hubcap screenshot mobile.png

See also

  • viewport - Set viewport dimensions only
  • useragent - Set user agent string only
  • tap - Tap an element (touch event)
  • swipe - Swipe gesture on the page
  • media - Emulate CSS media features