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 portraitloki run http://localhost:8000 -m pixel-7 --orientation landscapeloki 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_ALIASESinsrc/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 fullplaywright.sync_api.devicesdictionary. - Orientation (
--orientation portrait | landscape): Inlandscapemode, LOKI first checks if Playwright defines a native<Device> landscapeprofile; otherwise it clones the device descriptor and swapsviewport.widthandviewport.height. - Automatic Mobile Layout Audit: Enabling
--device/-mautomatically 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`)
| Flag | Type | Default | Description |
|---|---|---|---|
| iphone | alias | iPhone 17 | Default iPhone alias mapped to Playwright's iPhone 17 descriptor. |
| iphone-17 / iphone17 | alias | iPhone 17 | Apple iPhone 17 viewport, user-agent, and touch profile. |
| iphone-17-pro / iphone17pro | alias | iPhone 17 Pro | Apple iPhone 17 Pro viewport, user-agent, and touch profile. |
| iphone-16 / iphone16 | alias | iPhone 16 | Apple iPhone 16 viewport, user-agent, and touch profile. |
| iphone-16-pro / iphone16pro | alias | iPhone 16 Pro | Apple iPhone 16 Pro viewport, user-agent, and touch profile. |
| iphone-15 / iphone15 | alias | iPhone 15 | Apple iPhone 15 viewport, user-agent, and touch profile. |
| iphone-15-pro | alias | iPhone 15 Pro | Apple iPhone 15 Pro viewport, user-agent, and touch profile. |
| iphone-14 / iphone14 | alias | iPhone 14 | Apple iPhone 14 viewport, user-agent, and touch profile. |
| iphone-13 / iphone13 | alias | iPhone 13 | Apple iPhone 13 viewport, user-agent, and touch profile. |
| iphone-se | alias | iPhone SE | Compact Apple iPhone SE viewport — ideal for catching narrow-screen horizontal overflows. |
| pixel | alias | Pixel 10 | Default Google Pixel alias mapped to Pixel 10. |
| pixel-10 / pixel10 | alias | Pixel 10 | Google Pixel 10 Android viewport and Chrome Mobile user-agent. |
| pixel-9 | alias | Pixel 9 | Google Pixel 9 Android viewport and Chrome Mobile user-agent. |
| pixel-8 | alias | Pixel 8 | Google Pixel 8 Android viewport and Chrome Mobile user-agent. |
| pixel-7 / pixel7 | alias | Pixel 7 | Google Pixel 7 Android viewport and Chrome Mobile user-agent. |
| ipad / ipad-pro | alias | iPad Pro 11 | Apple iPad Pro 11 tablet viewport and touch profile. |
| ipad-mini | alias | iPad Mini | Apple iPad Mini compact tablet viewport and touch profile. |
| galaxy / galaxy-s24 | alias | Galaxy S24 | Samsung Galaxy S24 Android viewport and touch profile. |
| galaxy-z-fold-7 | alias | Galaxy Z Fold 7 | Samsung Galaxy Z Fold 7 foldable viewport profile. |
| galaxy-z-flip-7 | alias | Galaxy Z Flip 7 | Samsung Galaxy Z Flip 7 foldable viewport profile. |
