setMobileEmulation(config)code »
Configures Chrome to emulate a mobile device. For more information, refer to
the ChromeDriver project page on mobile emulation. Configuration
options include:
deviceName
: The name of a pre-configured emulated devicewidth
: screen width, in pixelsheight
: screen height, in pixelspixelRatio
: screen pixel ratio
Example 1: Using a Pre-configured Device
var options = new chrome.Options().setMobileEmulation(
{deviceName: 'Google Nexus 5'});
var driver = new chrome.Driver(options);
Example 2: Using Custom Screen Configuration
var options = new chrome.Options().setMobileEmulation({
width: 360,
height: 640,
pixelRatio: 3.0
});
var driver = new chrome.Driver(options);
Parameters
- config
?({deviceName: string}|{height: number, pixelRatio: number, width: number})
The
mobile emulation configuration, or null
to disable emulation.