Git Product home page Git Product logo

mobile-web-browser-emulator's Introduction

Dependency Status devDependency Status

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.

alt google screenshot alt w3c screenshot

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(
  // Parameters such as dimensions for tablets, smartphones or desktops.
  {
    url: 'https://www.google.com/', // URL to load. **required**
    width: 300, // Width of the device. **optional** (300 by default)
    height: 700 // Height of the device. **optional** (300 by default)
  },
	// The second parameter is a callback that takes a browser instance as an argument
	function(browser) { /* ... */ }
);

Methods on the browser object:

browser.do(function(driver) {
  // The driver object can then be used with Selenium WebDriver
});
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) { // Selenium Webdriver Method
      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

mobile-web-browser-emulator's People

Contributors

gbaudusseau avatar dontcallmedom avatar guibbs avatar astorije avatar tripu avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.