Developer Friendly Browser Automation

Try Now

Post to Twitter

  1. This bookmarklet will execute the above code with Browser Stig. Drag the bookmarklet to your bookmarks toolbar:
  2. In a new browser tab, log in to
  3. Click on the ✓ Browser Stig bookmark in your bookmarks toolbar.


npm install -g browserstig


Getting Started

  1. After installing browserstig, create a new directory:

    mkdir automation

    cd automation

  2. Initialize your project with a browserstig.conf.js configuration file and a main.js start file:

    stig init

  3. Run the sample test by running "stig" from the command-line with no options:



BrowserStig requires a browserstig.conf.js to be in the same directory that you run the "stig" CLI. The following options are supported:

BrowserStig API

browserstig.js is automatically included in the BrowserStig automation environment. This gives you access to the BrowserStig global in any of your js or coffee files that you include. However, you could also include browserstig.js standalone in any project.

Functional Testing with BrowserStig

Although BrowserStig may be used for other automation purposes, it's main purpose is to be used for functional testing. As mentioned before, you can use browserstig.js standalone without the cli. This would allow you to import browserstig.js into any javascript testing framework. However, the stig cli is designed to help you start testing immediately with minimal setup.

If you have used the karma test runner, you will be familiar with the stig cli. Really, the stig cli just wraps the karma test runner. The supported test styles are 'mocha', 'jasmine' and 'qunit'. However, this documentation only covers testing with mocha.


After running "stig init", your project will be initialized with a browserstig.conf.js and a main.js file. main.js is the first file that will be loaded into the browser. In this file we setup mocha to give a much longer timeout for tests. This is because functional tests usually take much longer to run than your typical unit test:

mocha.setup({timeout: 30000});

We also setup a "stig" global to be initialized before each test:

beforeEach(function ()
  stig = new BrowserStig();

We can now use the "stig" global in any of our tests. The following test is included in main.js by default:

describe('Amazon Test', function () {

  it('should get a result from the search', function (done) {'/');
    stig.el('.newaps:first .lrg.bold').text(function (text) {
      console.log('First Result: ' + text);
      assert(text.length > 0);


The most important thing to notice is that the test uses the asynchronous features of mocha. This is why the test function accepts a "done" callback that gets passed to the function. This tells mocha to wait for the test to finish all the way before moving on to run the next one.

This test is included directly in the main.js file, but it is best to distribute your tests in multiple files. This can be easily accomplished by setting the files property in your browserstig.conf.js. For example, if you wanted to run all of the tests in all of the js files beneath the "tests" directory of your project:

files: [ 'tests/**/*.js' ],

Example Project

Here is a pre-configured sample project that you may want to use to help you get started.

Known Issues

Please log any other issues on github