Mobile Web Browser Emulator
Mobile Web Browser Emulator is a Node.js tool which simulates a Chrome-based browser on a mobile device. This module also allows manipulation via Selenium WebDriver. It is an easy way to test mobile web applications on mobile devices.
This module is used by the new version of the Mobile Checker by W3C.
This application works in headless mode (powered via XVFB). Using it on the server side is easy.
Install
Start by having BrowserMob Proxy set up and running. Then run the following command
npm install mobile-web-browser-emulator
API
With Mobile Web Browser Emulator, it is easy test mobile web applications using the Selenium WebDriver API.
Emulation example:
var MobileBrowser = require('mobile-web-browser-emulator').MobileBrowser;
var mobileBrowser = new MobileBrowser();
mobileBrowser.emulate(
{
url: 'https://www.google.com/',
width: 300,
height: 700
},
function(browser) { }
);
Methods on the browser
object:
browser.do(function(driver) {
});
browser.takeScreenshot('example.png');
Manipulation with Selenium example :
var MobileBrowser = require('../lib/index.js').MobileBrowser;
var mobileBrowser = new MobileBrowser();
mobileBrowser.emulate({
url: 'https://www.google.com',
width: 300,
height: 700
}, function(browser) {
browser.do(function(driver) {
driver.getTitle().then(function(title) {
console.log(title);
});
});
});
Screenshot example:
var MobileBrowser = require('../lib/index.js').MobileBrowser;
var mobileBrowser = new MobileBrowser();
mobileBrowser.emulate({
url: 'https://www.google.com',
width: 300,
height: 700
}, function(browser) {
browser.takeScreenshot(__dirname + "/../screenshot.png");
});
Licence
Copyright (c) 2014 Dominique Hazael Massieux, Guillaume Baudusseau
MIT