Detect the browsers installed on your system and launch them in an isolated profile for automation & testing purposes. Supports Linux, Mac and Windows.
This project is the latest in a long series, each forked from the last:
substack/browser-launcher
(lightly maintained)benderjs/browser-launcher2
(unmaintained).james-proxy/james-browser-launcher
(unmaintained)httptoolkit/browser-launcher
(actively maintained)They all have their problems. This fork is temporary, meant to consolidate fixes and reduce API surface, after which it will be split up into small, community-owned modules. In other words, this fork exists so that the project can die a good death. Its API is subject to change without warning.
npm install the-last-browser-launcher
const launcher = require('the-last-browser-launcher')
launcher.detect(function(err, manifests) {
if (err) throw err
launcher.launch(manifests[0], 'http://example.com/', function(err, instance) {
if (err) throw 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
const launcher = require('the-last-browser-launcher')
launcher.detect(callback)
Get available browsers.
Parameters:
callback(err, manifests)
launcher.launch(manifest, uri[, options], callback)
Open given URI in a browser and yield an instance
of it.
Parameters:
manifest
- A manifest from detect()
uri
- URI to open in a newly started browseroptions
:
proxy
- URI of the proxy serverargs
- additional command line argumentsskipDefaults
- don't supply any default args to browserdetached
- if true, then killing your script will not kill the opened browsernoProxy
- An array of strings, containing proxy routes to skip overheadless
- run in headless mode. Supported cross-platform by Chromium, Chrome, Edge, Brave and Firefox.callback(err, instance)
instance
Browser instance object.
Properties:
process
- reference to instance's process started with Node's child_process.spawn
APIpid
- instance's process PIDstdout
- instance's process STDOUT streamstderr
- instance's process STDERR streamEvents:
stop
- fired when instance stopsMethods:
unref()
stop(callback)
- stop the instance and fire the callback once stoppedMIT