Mobile Emulation speeds up web development, allows developers to quickly test how a website will render in a mobile device, without requiring a real device. ChromeDriver can also enable Mobile Emulation, via the “mobileEmulation” capability, specified with a dictionary value.
Mobile Emulation
Chrome allows users to emulate Chrome on a mobile device (e.g. a “Nexus 7” tablet, or an “iPhone 5”) from the desktop version of Chrome, by enabling the Mobile Emulation feature in Chrome DevTools. This feature speeds up web development, allows developers to quickly test how a website will render in a mobile device, without requiring a real device. ChromeDriver can also enable Mobile Emulation, via the “mobileEmulation” capability, specified with a dictionary value.
Just as in the DevTools Emulation panel, there are two ways in ChromeDriver to enable Mobile Emulation: by specifying a known device, or by specifying individual device attributes. The format of the mobileEmulation
dictionary depends on which method is desired.
Specifying a Known Mobile Device
To enable Mobile Emulation with a specific device name, the mobileEmulation
dictionary must contain a deviceName
. Use a valid device name from the DevTools Emulation panel as the value for deviceName
.
Note that Mobile Emulation is subject to this known issue.