Launching chrome in mobile emulation in Selenium in node

Chrome driver allows you to test your web application on emulated mobile devices(Android and iOS). Below example illustrates how to launch chrome in Mobile Emulation using Selenium in Node.js
var assert = require(‘assert’);
var webdriver = require(‘selenium-webdriver’),
By = webdriver.By,
until = webdriver.until;

var chrome = require(“selenium-webdriver/chrome”);

//Below code snippet shows how to launch chrome with mobile emulation mode.
var driver = new webdriver.Builder()
.setChromeOptions(new chrome.Options()
.setMobileEmulation({deviceName: ‘Apple iPhone 5’})
//.setMobileEmulation({deviceName: ‘Google Nexus 5’})
//.setMobileEmulation({deviceName: ‘Google Nexus 7’})

//Rest of the operations will be done in emulation mode


Complex problems, Simple Solutions