Use steer to control your chrome (the browser)
npm install steer
You will need to install
google-chrome (not chromeium) on your machine first.
You can find it here: https://www.google.com/intl/en/chrome/browser/
This example starts a
google-chrome browser navigates to http://google.com and
then query the
var steer = ;var path = ;var chrome =;chrome;
As you can see the API is quite complicated but you do pretty anything with it. This module supports two binding APIs:
I would personally recomed using
WebKit remote inspector API, this is what
the "Chrome DevTools" uses, so you should be familiar with what's possible.
However it can do more than just what the GUI allows but sometimes you have
to use the Extension API as well.
Futhermore there are modules there abstacts the complicated API away, here are some:
When requireing this module you get a steer constructor.
var steer = ;
When createing a new instance a
google-chrome process is stared with it own
private profile. This means it won't interfere with other
var chrome = ;
steer contructor takes a warity of
settings where some are optional.
cache(required). The directory where the cached files will be stored. This should be reused when your application craches.
inspectorPort(required). A free port number for localhost used for the WebKit inspector protocol communication.
userAgent(optional). This is the user-agent header chrome will be using. If not set this will just the long user-agent chrome will usually send.
blocked(optional). An array of hostnames there will return a 404. This could be ad sites or other websites you don't which to spend time on.
size(optional). This will be the inner size of the chrome frame. By default this is
800is the width and
600is the height.
permissions(optional). This is an array of the permissions there should be given to the chrome extension there binds this module to the extension API.
var chrome =;
An insterface for the WebKit remote inspector API, for documentation see the inspector module.
For example, to navigate to a page:
A simple interface for the chrome extension API. For the full API see http://developer.chrome.com/extensions/api_index.html
For example, to take a screenshot do:
// Note this requires `taps` permissionsvar BASE64_URL_PREFIX = 'data:image/jpeg;base64,';chromeextension;
Another example, to clear the cookies and all other sort of browser states do:
// Note this requires `browsingData` permissionschromeextension;
The standard node process object for the
Close the browser in a gracefull way, this will cleanup the temporary
directories and shutdown the a server used for blocking requests and finally
close the browser. The optional callback is just attached to the
This will simply kill the browser. You should call
process.exit() after this
as there will still be active stuff running.
Everything is ready, you can start navigating the browser now. Until this
event fires you should expect
process to be
This event emits when the browser closes.
An error occurred. As there are many things running in order to manage the remote connection (actually there are more) this can be caused by quite a lot.
The software is license under "MIT"
Copyright (c) 2014 Peter V. T. Schlegel
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.