bump to 0.4.5
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.
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:
edp-browser-launcher2
npm install edp-browser-launcher2
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
var launcher = require( '../' ); launcher.detect( function( available ) { console.log( 'Available browsers:' ); console.dir( available ); } );
$ 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' } ]
var launcher = require('edp-browser-launcher2');
launcher([configPath], callback)
Detect available browsers and pass launch function to the callback.
launch
Parameters:
configPath
callback(err, launch)
launch(uri, options, callback)
Open given URI in a browser and return an instance of it.
uri
options
options.browser
options.version
options.options
options.proxy
options.noProxy
options.headless
callback(err, instance)
instance
launch.browsers
This property contains an array of all known and available browsers.
Browser instance object.
Properties:
command
args
image
processName
process
child_process.spawn
pid
stdout
stderr
Events:
stop
Methods:
stop(callback)
launcher.detect(callback)
Detects all browsers available.
callback(available)
Each browser contains following properties:
name
version
type
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.
~/.config/browser-launcher/config.json
configDir
callback(err, browsers)
MIT
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
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
Supported browsers
The goal for this module is to support all major browsers on every desktop platform.
At the moment,
edp-browser-launcher2supports following browsers on Windows, Unix and OS X:Install
Example
Browser launch
Outputs:
Browser detection
Outputs:
API
launcher([configPath], callback)Detect available browsers and pass
launchfunction to the callback.Parameters:
configPath- path to a browser configuration file (Optional)callback(err, launch)- function called withlaunchfunction and errors (if any)launch(uri, options, callback)Open given URI in a browser and return an instance of it.
Parameters:
uri- URI to open in a newly started browseroptions- configuration options or name of a browser to launchoptions.browser- name of a browser to launchoptions.version- version of a browser to launch, if none was given, the highest available version will be launchedoptions.options- additional command line optionsoptions.proxy- URI of the proxy serveroptions.noProxy- set proxy routes to skip overoptions.headless- run a browser in a headless mode (only if Xvfb available)callback(err, instance)- function fired when started a browserinstanceor an error occurredlaunch.browsersThis property contains an array of all known and available browsers.
instanceBrowser instance object.
Properties:
command- command used to start the instanceargs- array of command line arguments used while starting the instanceimage- instance’s image nameprocessName- instance’s process nameprocess- reference to instance’s process started with Node’schild_process.spawnAPIpid- instance’s process PIDstdout- instance’s process STDOUT streamstderr- instance’s process STDERR streamEvents:
stop- fired when instance stopsMethods:
stop(callback)- stop the instance and fire the callback once stoppedlauncher.detect(callback)Detects all browsers available.
Parameters:
callback(available)- function called with array of all recognized browsersEach browser contains following properties:
name- name of a browserversion- browser’s versiontype- type of a browser i.e. browser’s familycommand- command used to launch a browserlauncher.update([configDir], callback)Updates the browsers cache file (
~/.config/browser-launcher/config.jsonis noconfigDirwas given) and creates new profiles for found browsers.Parameters:
configDir- path to a directory containing configuration file Optionalcallback(err, browsers)- function called with found browsers and errors (if any)License
MIT