LOKI LogoLOKIv1.10.0

Mobile Emulation (`devices.py`)

Emulate mobile viewports, touch events, device scale factors, and orientations using aliases from src/loki/engine/devices.py.

Usage

bash
loki run http://localhost:8000 --device iphone-15 --orientation portrait
loki run http://localhost:8000 -m pixel-7 --orientation landscape
loki run http://localhost:8000 -m ipad-pro

How `resolve_device()` works

  • Alias normalization: Strips whitespace, converts to lowercase, maps spaces to hyphens, and resolves the name through DEVICE_ALIASES in src/loki/engine/devices.py.
  • Playwright catalog lookup: If the name is not in DEVICE_ALIASES, resolve_device() performs a case-insensitive exact match (and then substring match) against Playwright's full playwright.sync_api.devices dictionary.
  • Orientation (--orientation portrait | landscape): In landscape mode, LOKI first checks if Playwright defines a native <Device> landscape profile; otherwise it clones the device descriptor and swaps viewport.width and viewport.height.
  • Automatic Mobile Layout Audit: Enabling --device / -m automatically activates the Mobile Layout Overflow detector (scrollWidth > innerWidth, off-screen interactive buttons/links/inputs, and tiny touch targets < 24×24 px).

Complete `DEVICE_ALIASES` Reference (`devices.py`)

FlagTypeDefaultDescription
iphonealiasiPhone 17Default iPhone alias mapped to Playwright's iPhone 17 descriptor.
iphone-17 / iphone17aliasiPhone 17Apple iPhone 17 viewport, user-agent, and touch profile.
iphone-17-pro / iphone17proaliasiPhone 17 ProApple iPhone 17 Pro viewport, user-agent, and touch profile.
iphone-16 / iphone16aliasiPhone 16Apple iPhone 16 viewport, user-agent, and touch profile.
iphone-16-pro / iphone16proaliasiPhone 16 ProApple iPhone 16 Pro viewport, user-agent, and touch profile.
iphone-15 / iphone15aliasiPhone 15Apple iPhone 15 viewport, user-agent, and touch profile.
iphone-15-proaliasiPhone 15 ProApple iPhone 15 Pro viewport, user-agent, and touch profile.
iphone-14 / iphone14aliasiPhone 14Apple iPhone 14 viewport, user-agent, and touch profile.
iphone-13 / iphone13aliasiPhone 13Apple iPhone 13 viewport, user-agent, and touch profile.
iphone-sealiasiPhone SECompact Apple iPhone SE viewport — ideal for catching narrow-screen horizontal overflows.
pixelaliasPixel 10Default Google Pixel alias mapped to Pixel 10.
pixel-10 / pixel10aliasPixel 10Google Pixel 10 Android viewport and Chrome Mobile user-agent.
pixel-9aliasPixel 9Google Pixel 9 Android viewport and Chrome Mobile user-agent.
pixel-8aliasPixel 8Google Pixel 8 Android viewport and Chrome Mobile user-agent.
pixel-7 / pixel7aliasPixel 7Google Pixel 7 Android viewport and Chrome Mobile user-agent.
ipad / ipad-proaliasiPad Pro 11Apple iPad Pro 11 tablet viewport and touch profile.
ipad-minialiasiPad MiniApple iPad Mini compact tablet viewport and touch profile.
galaxy / galaxy-s24aliasGalaxy S24Samsung Galaxy S24 Android viewport and touch profile.
galaxy-z-fold-7aliasGalaxy Z Fold 7Samsung Galaxy Z Fold 7 foldable viewport profile.
galaxy-z-flip-7aliasGalaxy Z Flip 7Samsung Galaxy Z Flip 7 foldable viewport profile.