A high-level browser automation library.

Star on GitHub

Simple API

Every method is a simple English command: goto, refresh, click, type... you can check out Nightmare's full API here.

Nightmare lets you simplify deeply nested callbacks into a few sequential statements. Here's an example search on Yahoo:

Raw Phantomjs

phantom.create(function (ph) {
  ph.createPage(function (page) {'', function (status) {
      page.evaluate(function () {
        var el =
        el.value = 'github nightmare';
      }, function (result) {
        page.evaluate(function () {
          var el = document.querySelector('.searchsubmit');
          var event = document.createEvent('MouseEvent');
          event.initEvent('click', true, false);
        }, function (result) {

With Nightmare

yield Nightmare()
  .type('input[title="Search"]', 'github nightmare')

Install it

Nightmare and its plugins can be installed with npm:

$ npm install nightmare

The package exposes a JavaScript API.