npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

edp-browser-launcher2

v0.4.5

Published

Detect, launch and stop browser versions

Downloads

7

Readme

edp-browser-launcher2

Detect the browser versions available on your system and launch them in an isolated profile for automated testing purposes.

You can launch browsers headlessly (using Xvfb or with PhantomJS) and set the proxy configuration on the fly.

It's a fork of benderjs/browser-launcher2.

Differences from browser-launcher2

  • config directory relies on package name
  • change plist.parseFile to plist.parse

Supported browsers

The goal for this module is to support all major browsers on every desktop platform.

At the moment, edp-browser-launcher2 supports following browsers on Windows, Unix and OS X:

  • Chrome
  • Chromium
  • Firefox
  • IE (Windows only)
  • Opera
  • Safari
  • PhantomJS

Install

npm install edp-browser-launcher2

Example

Browser launch

var launcher = require( 'edp-browser-launcher2' );

launcher( function( err, launch ) {
	if ( err ) {
		return console.error( err );
	}

	launch( 'http://cksource.com/', 'chrome', function( err, instance ) {
		if ( err ) {
			return console.error( err );
		}

		console.log( 'Instance started with PID:', instance.pid );

		instance.on( 'stop', function( code ) {
			console.log( 'Instance stopped with exit code:', code );
		} );
	} );
} );

Outputs:

$ node example/launch.js
Instance started with PID: 12345
Instance stopped with exit code: 0

Browser detection

var launcher = require( '../' );

launcher.detect( function( available ) {
	console.log( 'Available browsers:' );
	console.dir( available );
} );

Outputs:

$ node example/detect.js
Available browsers:
[ { name: 'chrome',
    version: '36.0.1985.125',
    type: 'chrome',
    command: 'google-chrome' },
  { name: 'chromium',
    version: '36.0.1985.125',
    type: 'chrome',
    command: 'chromium-browser' },
  { name: 'firefox',
    version: '31.0',
    type: 'firefox',
    command: 'firefox' },
  { name: 'phantomjs',
    version: '1.9.7',
    type: 'phantom',
    command: 'phantomjs' },
  { name: 'opera',
    version: '12.16',
    type: 'opera',
    command: 'opera' } ]

API

var launcher = require('edp-browser-launcher2');

launcher([configPath], callback)

Detect available browsers and pass launch function to the callback.

Parameters:

  • String configPath - path to a browser configuration file (Optional)
  • Function callback(err, launch) - function called with launch function and errors (if any)

launch(uri, options, callback)

Open given URI in a browser and return an instance of it.

Parameters:

  • String uri - URI to open in a newly started browser
  • Object|String options - configuration options or name of a browser to launch
  • String options.browser - name of a browser to launch
  • String options.version - version of a browser to launch, if none was given, the highest available version will be launched
  • Array options.options - additional command line options
  • String options.proxy - URI of the proxy server
  • Boolean options.noProxy - set proxy routes to skip over
  • Boolean options.headless - run a browser in a headless mode (only if Xvfb available)
  • Function callback(err, instance) - function fired when started a browser instance or an error occurred

launch.browsers

This property contains an array of all known and available browsers.

instance

Browser instance object.

Properties:

  • String command - command used to start the instance
  • Array args - array of command line arguments used while starting the instance
  • String image - instance's image name
  • String processName - instance's process name
  • Object process - reference to instance's process started with Node's child_process.spawn API
  • Number pid - instance's process PID
  • Stream stdout - instance's process STDOUT stream
  • Stream stderr - instance's process STDERR stream

Events:

  • stop - fired when instance stops

Methods:

  • stop(callback) - stop the instance and fire the callback once stopped

launcher.detect(callback)

Detects all browsers available.

Parameters:

  • Function callback(available) - function called with array of all recognized browsers

Each browser contains following properties:

  • name - name of a browser
  • version - browser's version
  • type - type of a browser i.e. browser's family
  • command - command used to launch a browser

launcher.update([configDir], callback)

Updates the browsers cache file (~/.config/browser-launcher/config.json is no configDir was given) and creates new profiles for found browsers.

Parameters:

  • String configDir - path to a directory containing configuration file Optional
  • Function callback(err, browsers) - function called with found browsers and errors (if any)

License

MIT