Paul Irish
Paul Irish

Reputation: 49172

Using Mobile Emulation via Chrome's remote debugging protocol

I like the "device mode" mobile emulation from chrome devtools. But I'd like to use it from within a testing environment.

Chrome has a debugging protocol accessible via a port or chrome.debugger extension API. Can I enable emulation via that?

Upvotes: 1

Views: 658

Answers (1)

Paul Irish
Paul Irish

Reputation: 49172

First up, Chromedriver offers this as a first-class feature: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation

From the Chrome Remote Debugging Protocol, you can can use the setDeviceMetricsOverride command to initialize the essential mobile emulation characteristics.

Check out some projects on GitHub using setDeviceMetricsOverride for example code.

Upvotes: 2

Related Questions