NOTICE: This library is no longer maintained.

Build Status Join the chat at https://gitter.im/rosshinkley/nightmare

Nightmare

Nightmare is a high-level browser automation library from Segment.

The goal is to expose a few simple methods that mimic user actions (like goto, type and click), with an API that feels synchronous for each block of scripting, rather than deeply nested callbacks. It was originally designed for automating tasks across sites that don't have APIs, but is most often used for UI testing and crawling.

Under the covers it uses Electron, which is similar to PhantomJS but roughly twice as fast and more modern.

⚠️ Security Warning: We've implemented many of the security recommendations outlined by Electron to try and keep you safe, but undiscovered vulnerabilities may exist in Electron that could allow a malicious website to execute code on your computer. Avoid visiting untrusted websites.

🛠 Migrating to 3.x: You'll want to check out this issue before upgrading. We've worked hard to make improvements to nightmare while limiting the breaking changes and there's a good chance you won't need to do anything.

Niffy is a perceptual diffing tool built on Nightmare. It helps you detect UI changes and bugs across releases of your web app.

Daydream is a complementary chrome extension built by @stevenmiller888 that generates Nightmare scripts for you while you browse.

Many thanks to @matthewmueller and @rosshinkley for their help on Nightmare.

Examples

Let's search on DuckDuckGo:

const Nightmare = require('nightmare')
const nightmare = Nightmare({ show: true })

nightmare
  .goto('https://duckduckgo.com')
  .type('#search_form_input_homepage', 'github nightmare')
  .click('#search_button_homepage')
  .wait('#r1-0 a.result__a')
  .evaluate(() => document.querySelector('#r1-0 a.result__a').href)
  .end()
  .then(console.log)
  .catch(error => {
    console.error('Search failed:', error)
  })

You can run this with:

npm install --save nightmare
node example.js

Or, let's run some mocha tests:

const Nightmare = require('nightmare')
const chai = require('chai')
const expect = chai.expect

describe('test duckduckgo search results', () => {
  it('should find the nightmare github link first', function(done) {
    this.timeout('10s')

    const nightmare = Nightmare()
    nightmare
      .goto('https://duckduckgo.com')
      .type('#search_form_input_homepage', 'github nightmare')
      .click('#search_button_homepage')
      .wait('#links .result__a')
      .evaluate(() => document.querySelector('#links .result__a').href)
      .end()
      .then(link => {
        expect(link).to.equal('https://github.com/segmentio/nightmare')
        done()
      })
  })
})

You can see examples of every function in the tests here.

To get started with UI Testing, check out this quick start guide.

To install dependencies

npm install

To run the mocha tests

npm test

Node versions

Nightmare is intended to be run on NodeJS 4.x or higher.

API

Nightmare(options)

Creates a new instance that can navigate around the web. The available options are documented here, along with the following nightmare-specific options.

waitTimeout (default: 30s)

Throws an exception if the .wait() didn't return true within the set timeframe.

const nightmare = Nightmare({
  waitTimeout: 1000 // in ms
})
gotoTimeout (default: 30s)

Throws an exception if the .goto() didn't finish loading within the set timeframe. Note that, even though goto normally waits for all the resources on a page to load, a timeout exception is only raised if the DOM itself has not yet loaded.

const nightmare = Nightmare({
  gotoTimeout: 1000 // in ms
})
loadTimeout (default: infinite)

Forces Nightmare to move on if a page transition caused by an action (eg, .click()) didn't finish within the set timeframe. If loadTimeout is shorter than gotoTimeout, the exceptions thrown by gotoTimeout will be suppressed.

const nightmare = Nightmare({
  loadTimeout: 1000 // in ms
})
executionTimeout (default: 30s)

The maximum amount of time to wait for an .evaluate() statement to complete.

const nightmare = Nightmare({
  executionTimeout: 1000 // in ms
})
paths

The default system paths that Electron knows about. Here's a list of available paths: https://github.com/atom/electron/blob/master/docs/api/app.md#appgetpathname

You can overwrite them in Nightmare by doing the following:

const nightmare = Nightmare({
  paths: {
    userData: '/user/data'
  }
})
switches

The command line switches used by the Chrome browser that are also supported by Electron. Here's a list of supported Chrome command line switches: https://github.com/atom/electron/blob/master/docs/api/chrome-command-line-switches.md

const nightmare = Nightmare({
  switches: {
    'proxy-server': '1.2.3.4:5678',
    'ignore-certificate-errors': true
  }
})
electronPath

The path to the prebuilt Electron binary. This is useful for testing on different versions of Electron. Note that Nightmare only supports the version on which this package depends. Use this option at your own risk.

const nightmare = Nightmare({
  electronPath: require('electron')
})
dock (OS X)

A boolean to optionally show the Electron icon in the dock (defaults to false). This is useful for testing purposes.

const nightmare = Nightmare({
  dock: true
})
openDevTools

Optionally shows the DevTools in the Electron window using true, or use an object hash containing mode: 'detach' to show in a separate window. The hash gets passed to contents.openDevTools() to be handled. This is also useful for testing purposes. Note that this option is honored only if show is set to true.

const nightmare = Nightmare({
  openDevTools: {
    mode: 'detach'
  },
  show: true
})
typeInterval (default: 100ms)

How long to wait between keystrokes when using .type().

const nightmare = Nightmare({
  typeInterval: 20
})
pollInterval (default: 250ms)

How long to wait between checks for the .wait() condition to be successful.

const nightmare = Nightmare({
  pollInterval: 50 //in ms
})
maxAuthRetries (default: 3)

Defines the number of times to retry an authentication when set up with .authenticate().

const nightmare = Nightmare({
  maxAuthRetries: 3
})

certificateSubjectName

A string to determine the client certificate selected by electron. If this options is set, the select-client-certificate event will be set to loop through the certificateList and find the first certificate that matches subjectName on the electron Certificate Object.

const nightmare = Nightmare({
  certificateSubjectName: 'tester'
})

.engineVersions()

Gets the versions for Electron and Chromium.

.useragent(useragent)

Sets the useragent used by electron.

.authentication(user, password)

Sets the user and password for accessing a web page using basic authentication. Be sure to set it before calling .goto(url).

.end()

Completes any queue operations, disconnect and close the electron process. Note that if you're using promises, .then() must be called after .end() to run the .end() task. Also note that if using an .end() callback, the .end() call is equivalent to calling .end() followed by .then(fn). Consider:

nightmare
  .goto(someUrl)
  .end(() => 'some value')
  //prints "some value"
  .then(console.log)

.halt(error, done)

Clears all queued operations, kills the electron process, and passes error message or 'Nightmare Halted' to an unresolved promise. Done will be called after the process has exited.

Interact with the Page

.goto(url[, headers])

Loads the page at url. Optionally, a headers hash can be supplied to set headers on the goto request.

When a page load is successful, goto returns an object with metadata about the page load, including:

  • url: The URL that was loaded
  • code: The HTTP status code (e.g. 200, 404, 500)
  • method: The HTTP method used (e.g. "GET", "POST")
  • referrer: The page that the window was displaying prior to this load or an empty string if this is the first page load.
  • headers: An object representing the response headers for the request as in {header1-name: header1-value, header2-name: header2-value}

If the page load fails, the error will be an object with the following properties:

Note that any valid response from a server is considered “successful.” That means things like 404 “not found” errors are successful results for goto. Only things that would cause no page to appear in the browser window, such as no server responding at the given address, the server hanging up in the middle of a response, or invalid URLs, are errors.

You can also adjust how long goto will wait before timing out by setting the gotoTimeout option on the Nightmare constructor.

.back()

Goes back to the previous page.

.forward()

Goes forward to the next page.

.refresh()

Refreshes the current page.

.click(selector)

Clicks the selector element once.

.mousedown(selector)

Mousedowns the selector element once.

.mouseup(selector)

Mouseups the selector element once.

.mouseover(selector)

Mouseovers the selector element once.

.mouseout(selector)

Mouseout the selector element once.

.type(selector[, text])

Enters the text provided into the selector element. Empty or falsey values provided for text will clear the selector's value.

.type() mimics a user typing in a textbox and will emit the proper keyboard events.

Key presses can also be fired using Unicode values with .type(). For example, if you wanted to fire an enter key press, you would write .type('body', '\u000d').

If you don't need the keyboard events, consider using .insert() instead as it will be faster and more robust.

.insert(selector[, text])

Similar to .type(), .insert() enters the text provided into the selector element. Empty or falsey values provided for text will clear the selector's value.

.insert() is faster than .type() but does not trigger the keyboard events.

.check(selector)

Checks the selector checkbox element.

.uncheck(selector)

Unchecks the selector checkbox element.

.select(selector, option)

Changes the selector dropdown element to the option with attribute [value=option]

.scrollTo(top, left)

Scrolls the page to desired position. top and left are always relative to the top left corner of the document.

.viewport(width, height)

Sets the viewport size.

.inject(type, file)

Injects a local file onto the current page. The file type must be either js or css.

.evaluate(fn[, arg1, arg2,...])

Invokes fn on the page with arg1, arg2,.... All the args are optional. On completion it returns the return value of fn. Useful for extracting information from the page. Here's an example:

const selector = 'h1'
nightmare
  .evaluate(selector => {
    // now we're executing inside the browser scope.
    return document.querySelector(selector).innerText
  }, selector) // <-- that's how you pass parameters from Node scope to browser scope
  .then(text => {
    // ...
  })

Error-first callbacks are supported as a part of evaluate(). If the arguments passed are one fewer than the arguments expected for the evaluated function, the evaluation will be passed a callback as the last parameter to the function. For example:

const selector = 'h1'
nightmare
  .evaluate((selector, done) => {
    // now we're executing inside the browser scope.
    setTimeout(
      () => done(null, document.querySelector(selector).innerText),
      2000
    )
  }, selector)
  .then(text => {
    // ...
  })

Note that callbacks support only one value argument (eg function(err, value)). Ultimately, the callback will get wrapped in a native Promise and only be able to resolve a single value.

Promises are also supported as a part of evaluate(). If the return value of the function has a then member, .evaluate() assumes it is waiting for a promise. For example:

const selector = 'h1';
nightmare
  .evaluate((selector) => (
    new Promise((resolve, reject) => {
      setTimeout(() => resolve(document.querySelector(selector).innerText), 2000);
    )}, selector)
  )
  .then((text) => {
    // ...
  })

.wait(ms)

Waits for ms milliseconds e.g. .wait(5000).

.wait(selector)

Waits until the element selector is present e.g. .wait('#pay-button').

.wait(fn[, arg1, arg2,...])

Waits until the fn evaluated on the page with arg1, arg2,... returns true. All the args are optional. See .evaluate() for usage.

.header(header, value)

Adds a header override for all HTTP requests. If header is undefined, the header overrides will be reset.

Extract from the Page

.exists(selector)

Returns whether the selector exists or not on the page.

.visible(selector)

Returns whether the selector is visible or not.

.on(event, callback)

Captures page events with the callback. You have to call .on() before calling .goto(). Supported events are documented here.

Additional "page" events
.on('page', function(type="error", message, stack))

This event is triggered if any javascript exception is thrown on the page. But this event is not triggered if the injected javascript code (e.g. via .evaluate()) is throwing an exception.

"page" events

Listens for window.addEventListener('error'), alert(...), prompt(...) & confirm(...).

.on('page', function(type="error", message, stack))

Listens for top-level page errors. This will get triggered when an error is thrown on the page.

.on('page', function(type="alert", message))

Nightmare disables window.alert from popping up by default, but you can still listen for the contents of the alert dialog.

.on('page', function(type="prompt", message, response))

Nightmare disables window.prompt from popping up by default, but you can still listen for the message to come up. If you need to handle the confirmation differently, you'll need to use your own preload script.

.on('page', function(type="confirm", message, response))

Nightmare disables window.confirm from popping up by default, but you can still listen for the message to come up. If you need to handle the confirmation differently, you'll need to use your own preload script.

.on('console', function(type [, arguments, ...]))

type will be either log, warn or error and arguments are what gets passed from the console. This event is not triggered if the injected javascript code (e.g. via .evaluate()) is using console.log.

.once(event, callback)

Similar to .on(), but captures page events with the callback one time.

.removeListener(event, callback)

Removes a given listener callback for an event.

.screenshot([path][, clip])

Takes a screenshot of the current page. Useful for debugging. The output is always a png. Both arguments are optional. If path is provided, it saves the image to the disk. Otherwise it returns a Buffer of the image data. If clip is provided (as documented here), the image will be clipped to the rectangle.

.html(path, saveType)

Saves the current page as html as files to disk at the given path. Save type options are here.

.pdf(path, options)

Saves a PDF to the specified path. Options are here.

.title()

Returns the title of the current page.

.url()

Returns the url of the current page.

.path()

Returns the path name of the current page.

Cookies

.cookies.get(name)

Gets a cookie by it's name. The url will be the current url.

.cookies.get(query)

Queries multiple cookies with the query object. If a query.name is set, it will return the first cookie it finds with that name, otherwise it will query for an array of cookies. If no query.url is set, it will use the current url. Here's an example:

// get all google cookies that are secure
// and have the path `/query`
nightmare
  .goto('http://google.com')
  .cookies.get({
    path: '/query',
    secure: true
  })
  .then(cookies => {
    // do something with the cookies
  })

Available properties are documented here: https://github.com/atom/electron/blob/master/docs/api/session.md#sescookiesgetdetails-callback

.cookies.get()

Gets all the cookies for the current url. If you'd like get all cookies for all urls, use: .get({ url: null }).

.cookies.set(name, value)

Sets a cookie's name and value. This is the most basic form, and the url will be the current url.

.cookies.set(cookie)

Sets a cookie. If cookie.url is not set, it will set the cookie on the current url. Here's an example:

nightmare
  .goto('http://google.com')
  .cookies.set({
    name: 'token',
    value: 'some token',
    path: '/query',
    secure: true
  })
  // ... other actions ...
  .then(() => {
    // ...
  })

Available properties are documented here: https://github.com/atom/electron/blob/master/docs/api/session.md#sescookiessetdetails-callback

.cookies.set(cookies)

Sets multiple cookies at once. cookies is an array of cookie objects. Take a look at the .cookies.set(cookie) documentation above for a better idea of what cookie should look like.

.cookies.clear([name])

Clears a cookie for the current domain. If name is not specified, all cookies for the current domain will be cleared.

nightmare
  .goto('http://google.com')
  .cookies.clear('SomeCookieName')
  // ... other actions ...
  .then(() => {
    // ...
  })

.cookies.clearAll()

Clears all cookies for all domains.

nightmare
  .goto('http://google.com')
  .cookies.clearAll()
  // ... other actions ...
  .then(() => {
    //...
  })

Proxies

Proxies are supported in Nightmare through switches.

If your proxy requires authentication you also need the authentication call.

The following example not only demonstrates how to use proxies, but you can run it to test if your proxy connection is working:

import Nightmare from 'nightmare';

const proxyNightmare = Nightmare({
  switches: {
    'proxy-server': 'my_proxy_server.example.com:8080' // set the proxy server here ...
  },
  show: true
});

proxyNightmare
  .authentication('proxyUsername', 'proxyPassword') // ... and authenticate here before `goto`
  .goto('http://www.ipchicken.com')
  .evaluate(() => {
    return document.querySelector('b').innerText.replace(/[^\d\.]/g, '');
  })
  .end()
  .then((ip) => { // This will log the Proxy's IP
    console.log('proxy IP:', ip);
  });

// The rest is just normal Nightmare to get your local IP
const regularNightmare = Nightmare({ show: true });

regularNightmare
  .goto('http://www.ipchicken.com')
  .evaluate(() =>
    document.querySelector('b').innerText.replace(/[^\d\.]/g, '');
  )
  .end()
  .then((ip) => { // This will log the your local IP
    console.log('local IP:', ip);
  });

Promises

By default, Nightmare uses default native ES6 promises. You can plug in your favorite ES6-style promises library like bluebird or q for convenience!

Here's an example:

var Nightmare = require('nightmare')

Nightmare.Promise = require('bluebird')
// OR:
Nightmare.Promise = require('q').Promise

You can also specify a custom Promise library per-instance with the Promise constructor option like so:

var Nightmare = require('nightmare')

var es6Nightmare = Nightmare()
var bluebirdNightmare = Nightmare({
  Promise: require('bluebird')
})

var es6Promise = es6Nightmare
  .goto('https://github.com/segmentio/nightmare')
  .then()
var bluebirdPromise = bluebirdNightmare
  .goto('https://github.com/segmentio/nightmare')
  .then()

es6Promise.isFulfilled() // throws: `TypeError: es6EndPromise.isFulfilled is not a function`
bluebirdPromise.isFulfilled() // returns: `true | false`

Extending Nightmare

Nightmare.action(name, [electronAction|electronNamespace], action|namespace)

You can add your own custom actions to the Nightmare prototype. Here's an example:

Nightmare.action('size', function(done) {
  this.evaluate_now(() => {
    const w = Math.max(
      document.documentElement.clientWidth,
      window.innerWidth || 0
    )
    const h = Math.max(
      document.documentElement.clientHeight,
      window.innerHeight || 0
    )
    return {
      height: h,
      width: w
    }
  }, done)
})

Nightmare()
  .goto('http://cnn.com')
  .size()
  .then(size => {
    //... do something with the size information
  })

Remember, this is attached to the static class Nightmare, not the instance.

You'll notice we used an internal function evaluate_now. This function is different than nightmare.evaluate because it runs it immediately, whereas nightmare.evaluate is queued.

An easy way to remember: when in doubt, use evaluate. If you're creating custom actions, use evaluate_now. The technical reason is that since our action has already been queued and we're running it now, we shouldn't re-queue the evaluate function.

We can also create custom namespaces. We do this internally for nightmare.cookies.get and nightmare.cookies.set. These are useful if you have a bundle of actions you want to expose, but it will clutter up the main nightmare object. Here's an example of that:

Nightmare.action('style', {
  background(done) {
    this.evaluate_now(
      () => window.getComputedStyle(document.body, null).backgroundColor,
      done
    )
  }
})

Nightmare()
  .goto('http://google.com')
  .style.background()
  .then(background => {
    // ... do something interesting with background
  })

You can also add custom Electron actions. The additional Electron action or namespace actions take name, options, parent, win, renderer, and done. Note the Electron action comes first, mirroring how .evaluate() works. For example:

Nightmare.action(
  'clearCache',
  (name, options, parent, win, renderer, done) => {
    parent.respondTo('clearCache', done => {
      win.webContents.session.clearCache(done)
    })
    done()
  },
  function(done) {
    this.child.call('clearCache', done)
  }
)

Nightmare()
  .clearCache()
  .goto('http://example.org')
  //... more actions ...
  .then(() => {
    // ...
  })

...would clear the browser’s cache before navigating to example.org.

See this document for more details on creating custom actions.

.use(plugin)

nightmare.use is useful for reusing a set of tasks on an instance. Check out nightmare-swiftly for some examples.

Custom preload script

If you need to do something custom when you first load the window environment, you can specify a custom preload script. Here's how you do that:

import path from 'path'

const nightmare = Nightmare({
  webPreferences: {
    preload: path.resolve('custom-script.js')
    //alternative: preload: "absolute/path/to/custom-script.js"
  }
})

The only requirement for that script is that you'll need the following prelude:

window.__nightmare = {}
__nightmare.ipc = require('electron').ipcRenderer

To benefit of all of nightmare's feedback from the browser, you can instead copy the contents of nightmare's preload script.

Storage Persistence between nightmare instances

By default nightmare will create an in-memory partition for each instance. This means that any localStorage or cookies or any other form of persistent state will be destroyed when nightmare is ended. If you would like to persist state between instances you can use the webPreferences.partition api in electron.

import Nightmare from 'nightmare';

nightmare = Nightmare(); // non persistent paritition by default
yield nightmare
  .evaluate(() => {
    window.localStorage.setItem('testing', 'This will not be persisted');
  })
  .end();

nightmare = Nightmare({
  webPreferences: {
    partition: 'persist: testing'
  }
});
yield nightmare
  .evaluate(() => {
    window.localStorage.setItem('testing', 'This is persisted for other instances with the same paritition name');
  })
  .end();

If you specify a null paritition then it will use the electron default behavior (persistent) or any string that starts with 'persist:' will persist under that partition name, any other string will result in in-memory only storage.

Usage

Installation

Nightmare is a Node.js module, so you'll need to have Node.js installed. Then you just need to npm install the module:

$ npm install --save nightmare

Execution

Nightmare is a node module that can be used in a Node.js script or module. Here's a simple script to open a web page:

import Nightmare from 'nightmare';

const nightmare = Nightmare();

nightmare.goto('http://cnn.com')
  .evaluate(() => {
    return document.title;
  })
  .end()
  .then((title) => {
    console.log(title);
  })

If you save this as cnn.js, you can run it on the command line like this:

npm install --save nightmare
node cnn.js

Common Execution Problems

Nightmare heavily relies on Electron for heavy lifting. And Electron in turn relies on several UI-focused dependencies (eg. libgtk+) which are often missing from server distros.

For help running nightmare on your server distro check out How to run nightmare on Amazon Linux and CentOS guide.

Debugging

There are three good ways to get more information about what's happening inside the headless browser:

  1. Use the DEBUG=* flag described below.
  2. Pass { show: true } to the nightmare constructor to have it create a visible, rendered window where you can watch what is happening.
  3. Listen for specific events.

To run the same file with debugging output, run it like this DEBUG=nightmare node cnn.js (on Windows use set DEBUG=nightmare & node cnn.js).

This will print out some additional information about what's going on:

nightmare queueing action "goto" +0ms
nightmare queueing action "evaluate" +4ms
Breaking News, U.S., World, Weather, Entertainment & Video News - CNN.com
Debug Flags

All nightmare messages

DEBUG=nightmare*

Only actions

DEBUG=nightmare:actions*

Only logs

DEBUG=nightmare:log*

Additional Resources

Tests

Automated tests for nightmare itself are run using Mocha and Chai, both of which will be installed via npm install. To run nightmare's tests, just run make test.

When the tests are done, you'll see something like this:

make test
  ․․․․․․․․․․․․․․․․․․
  18 passing (1m)

Note that if you are using xvfb, make test will automatically run the tests under an xvfb-run wrapper. If you are planning to run the tests headlessly without running xvfb first, set the HEADLESS environment variable to 0.

License (MIT)

WWWWWW||WWWWWW
 W W W||W W W
      ||
    ( OO )__________
     /  |           \
    /o o|    MIT     \
    \___/||_||__||_|| *
         || ||  || ||
        _||_|| _||_||
       (__|__|(__|__|

Copyright (c) 2015 Segment.io, Inc. mailto:[email protected]

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.

segment-boneyard/nightmare

{
"props": {
"initialPayload": {
"allShortcutsEnabled": false,
"path": "/",
"repo": {
"id": 18477927,
"defaultBranch": "master",
"name": "nightmare",
"ownerLogin": "segment-boneyard",
"currentUserCanPush": false,
"isFork": false,
"isEmpty": false,
"createdAt": "2014-04-05T22:19:51.000Z",
"ownerAvatar": "https://avatars.githubusercontent.com/u/11205156?v=4",
"public": true,
"private": false,
"isOrgOwned": true
},
"currentUser": null,
"refInfo": {
"name": "master",
"listCacheKey": "v0:1696530306.0",
"canEdit": false,
"refType": "branch",
"currentOid": "0f47de84991243cc040e8e020f7aee847c7c4a0e"
},
"tree": {
"items": [
{
"name": ".circleci",
"path": ".circleci",
"contentType": "directory"
},
{
"name": "lib",
"path": "lib",
"contentType": "directory"
},
{
"name": "test",
"path": "test",
"contentType": "directory"
},
{
"name": ".eslintrc.js",
"path": ".eslintrc.js",
"contentType": "file"
},
{
"name": ".gitignore",
"path": ".gitignore",
"contentType": "file"
},
{
"name": "History.md",
"path": "History.md",
"contentType": "file"
},
{
"name": "Makefile",
"path": "Makefile",
"contentType": "file"
},
{
"name": "Readme.md",
"path": "Readme.md",
"contentType": "file"
},
{
"name": "example.js",
"path": "example.js",
"contentType": "file"
},
{
"name": "package-lock.json",
"path": "package-lock.json",
"contentType": "file"
},
{
"name": "package.json",
"path": "package.json",
"contentType": "file"
}
],
"templateDirectorySuggestionUrl": null,
"readme": null,
"totalCount": 11,
"showBranchInfobar": false
},
"fileTree": null,
"fileTreeProcessingTime": null,
"foldersToFetch": [],
"treeExpanded": false,
"symbolsExpanded": false,
"isOverview": true,
"overview": {
"banners": {
"shouldRecommendReadme": false,
"isPersonalRepo": false,
"showUseActionBanner": false,
"actionSlug": null,
"actionId": null,
"showProtectBranchBanner": false,
"recentlyTouchedDataChannel": null,
"publishBannersInfo": {
"dismissActionNoticePath": "/settings/dismiss-notice/publish_action_from_repo",
"releasePath": "/segment-boneyard/nightmare/releases/new?marketplace=true",
"showPublishActionBanner": false
},
"interactionLimitBanner": null,
"showInvitationBanner": false,
"inviterName": null
},
"codeButton": {
"contactPath": "/contact",
"isEnterprise": false,
"local": {
"protocolInfo": {
"httpAvailable": true,
"sshAvailable": null,
"httpUrl": "https://github.com/segment-boneyard/nightmare.git",
"showCloneWarning": null,
"sshUrl": null,
"sshCertificatesRequired": null,
"sshCertificatesAvailable": null,
"ghCliUrl": "gh repo clone segment-boneyard/nightmare",
"defaultProtocol": "http",
"newSshKeyUrl": "/settings/ssh/new",
"setProtocolPath": "/users/set_protocol"
},
"platformInfo": {
"cloneUrl": "https://desktop.github.com",
"showVisualStudioCloneButton": false,
"visualStudioCloneUrl": "https://windows.github.com",
"showXcodeCloneButton": false,
"xcodeCloneUrl": "https://developer.apple.com",
"zipballUrl": "/segment-boneyard/nightmare/archive/refs/heads/master.zip"
}
},
"newCodespacePath": "/codespaces/new?hide_repo_select=true&repo=18477927"
},
"popovers": {
"rename": null,
"renamedParentRepo": null
},
"commitCount": "994",
"overviewFiles": [
{
"displayName": "Readme.md",
"repoName": "nightmare",
"refName": "master",
"path": "Readme.md",
"preferredFileType": "readme",
"tabName": "README",
"richText": "<article class=\"markdown-body entry-content container-lg\" itemprop=\"text\"><p dir=\"auto\"><em>NOTICE: This library is no longer maintained.</em></p>\n<p dir=\"auto\"><a href=\"https://circleci.com/gh/segmentio/nightmare\" rel=\"nofollow\"><img src=\"https://camo.githubusercontent.com/7600ecdb0389bad5967d8f54bbdb691f48055a71ab40b6c322f9db4d6a93a8d4/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f7365676d656e74696f2f6e696768746d6172652f6d61737465722e737667\" alt=\"Build Status\" data-canonical-src=\"https://img.shields.io/circleci/project/segmentio/nightmare/master.svg\" style=\"max-width: 100%;\"></a>\n<a href=\"https://gitter.im/rosshinkley/nightmare?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\" rel=\"nofollow\"><img src=\"https://camo.githubusercontent.com/8119e51a40fc7dbc60d52db8f38bc362984e4c2982046900f148d93a4cf161ba/68747470733a2f2f6261646765732e6769747465722e696d2f726f737368696e6b6c65792f6e696768746d6172652e737667\" alt=\"Join the chat at https://gitter.im/rosshinkley/nightmare\" data-canonical-src=\"https://badges.gitter.im/rosshinkley/nightmare.svg\" style=\"max-width: 100%;\"></a></p>\n<h1 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-nightmare\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#nightmare\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Nightmare</h1>\n<p dir=\"auto\">Nightmare is a high-level browser automation library from <a href=\"https://segment.com\" rel=\"nofollow\">Segment</a>.</p>\n<p dir=\"auto\">The goal is to expose a few simple methods that mimic user actions (like <code>goto</code>, <code>type</code> and <code>click</code>), with an API that feels synchronous for each block of scripting, rather than deeply nested callbacks. It was originally designed for automating tasks across sites that don't have APIs, but is most often used for UI testing and crawling.</p>\n<p dir=\"auto\">Under the covers it uses <a href=\"http://electron.atom.io/\" rel=\"nofollow\">Electron</a>, which is similar to <a href=\"http://phantomjs.org/\" rel=\"nofollow\">PhantomJS</a> but roughly <a href=\"https://github.com/segmentio/nightmare/issues/484#issuecomment-184519591\" data-hovercard-type=\"issue\" data-hovercard-url=\"/segment-boneyard/nightmare/issues/484/hovercard\">twice as fast</a> and more modern.</p>\n<p dir=\"auto\"><strong><g-emoji class=\"g-emoji\" alias=\"warning\">⚠️</g-emoji> Security Warning:</strong> We've implemented <a href=\"https://github.com/segmentio/nightmare/issues/1388\" data-hovercard-type=\"issue\" data-hovercard-url=\"/segment-boneyard/nightmare/issues/1388/hovercard\">many</a> of the security recommendations <a href=\"https://github.com/electron/electron/blob/master/docs/tutorial/security.md\">outlined by Electron</a> to try and keep you safe, but undiscovered vulnerabilities may exist in Electron that could allow a malicious website to execute code on your computer. Avoid visiting untrusted websites.</p>\n<p dir=\"auto\"><strong>🛠 Migrating to 3.x:</strong> You'll want to check out <a href=\"https://github.com/segmentio/nightmare/issues/1396\" data-hovercard-type=\"issue\" data-hovercard-url=\"/segment-boneyard/nightmare/issues/1396/hovercard\">this issue</a> before upgrading. We've worked hard to make improvements to nightmare while limiting the breaking changes and there's a good chance you won't need to do anything.</p>\n<p dir=\"auto\"><a href=\"https://github.com/segmentio/niffy\">Niffy</a> is a perceptual diffing tool built on Nightmare. It helps you detect UI changes and bugs across releases of your web app.</p>\n<p dir=\"auto\"><a href=\"https://github.com/segmentio/daydream\">Daydream</a> is a complementary chrome extension built by <a href=\"https://github.com/stevenmiller888\">@stevenmiller888</a> that generates Nightmare scripts for you while you browse.</p>\n<p dir=\"auto\">Many thanks to <a href=\"https://github.com/matthewmueller\">@matthewmueller</a> and <a href=\"https://github.com/rosshinkley\">@rosshinkley</a> for their help on Nightmare.</p>\n<ul dir=\"auto\">\n<li><a href=\"#examples\">Examples</a>\n<ul dir=\"auto\">\n<li><a href=\"https://segment.com/blog/ui-testing-with-nightmare/\" rel=\"nofollow\">UI Testing Quick Start</a></li>\n<li><a href=\"https://segment.com/blog/perceptual-diffing-with-niffy/\" rel=\"nofollow\">Perceptual Diffing with Niffy &amp; Nightmare</a></li>\n</ul>\n</li>\n<li><a href=\"#api\">API</a>\n<ul dir=\"auto\">\n<li><a href=\"#nightmareoptions\">Set up an instance</a></li>\n<li><a href=\"#interact-with-the-page\">Interact with the page</a></li>\n<li><a href=\"#extract-from-the-page\">Extract from the page</a></li>\n<li><a href=\"#cookies\">Cookies</a></li>\n<li><a href=\"#proxies\">Proxies</a></li>\n<li><a href=\"#promises\">Promises</a></li>\n<li><a href=\"#extending-nightmare\">Extending Nightmare</a></li>\n</ul>\n</li>\n<li><a href=\"#usage\">Usage</a></li>\n<li><a href=\"#debugging\">Debugging</a></li>\n<li><a href=\"#additional-resources\">Additional Resources</a></li>\n</ul>\n<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-examples\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#examples\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Examples</h2>\n<p dir=\"auto\">Let's search on DuckDuckGo:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const Nightmare = require('nightmare')\nconst nightmare = Nightmare({ show: true })\n\nnightmare\n .goto('https://duckduckgo.com')\n .type('#search_form_input_homepage', 'github nightmare')\n .click('#search_button_homepage')\n .wait('#r1-0 a.result__a')\n .evaluate(() =&gt; document.querySelector('#r1-0 a.result__a').href)\n .end()\n .then(console.log)\n .catch(error =&gt; {\n console.error('Search failed:', error)\n })\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-v\">Nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'nightmare'</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span> <span class=\"pl-c1\">show</span>: <span class=\"pl-c1\">true</span> <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n\n<span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'https://duckduckgo.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">type</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'#search_form_input_homepage'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s\">'github nightmare'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">click</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'#search_button_homepage'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">wait</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'#r1-0 a.result__a'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">querySelector</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'#r1-0 a.result__a'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">href</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">end</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">log</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">catch</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">error</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">error</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'Search failed:'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">error</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">You can run this with:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm install --save nightmare\nnode example.js\"><pre>npm install --save nightmare\nnode example.js</pre></div>\n<p dir=\"auto\">Or, let's run some mocha tests:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const Nightmare = require('nightmare')\nconst chai = require('chai')\nconst expect = chai.expect\n\ndescribe('test duckduckgo search results', () =&gt; {\n it('should find the nightmare github link first', function(done) {\n this.timeout('10s')\n\n const nightmare = Nightmare()\n nightmare\n .goto('https://duckduckgo.com')\n .type('#search_form_input_homepage', 'github nightmare')\n .click('#search_button_homepage')\n .wait('#links .result__a')\n .evaluate(() =&gt; document.querySelector('#links .result__a').href)\n .end()\n .then(link =&gt; {\n expect(link).to.equal('https://github.com/segmentio/nightmare')\n done()\n })\n })\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-v\">Nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'nightmare'</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-s1\">chai</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'chai'</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-s1\">expect</span> <span class=\"pl-c1\">=</span> <span class=\"pl-s1\">chai</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">expect</span>\n\n<span class=\"pl-en\">describe</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'test duckduckgo search results'</span><span class=\"pl-kos\">,</span> <span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-en\">it</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'should find the nightmare github link first'</span><span class=\"pl-kos\">,</span> <span class=\"pl-k\">function</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">this</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">timeout</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'10s'</span><span class=\"pl-kos\">)</span>\n\n <span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'https://duckduckgo.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">type</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'#search_form_input_homepage'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s\">'github nightmare'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">click</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'#search_button_homepage'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">wait</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'#links .result__a'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">querySelector</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'#links .result__a'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">href</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">end</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">link</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-s1\">expect</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">link</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">to</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">equal</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'https://github.com/segmentio/nightmare'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-s1\">done</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">You can see examples of every function <a href=\"https://github.com/segmentio/nightmare/blob/master/test/index.js\">in the tests here</a>.</p>\n<p dir=\"auto\">To get started with UI Testing, check out this <a href=\"https://segment.com/blog/ui-testing-with-nightmare\" rel=\"nofollow\">quick start guide</a>.</p>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-to-install-dependencies\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#to-install-dependencies\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>To install dependencies</h3>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"npm install\"><pre class=\"notranslate\"><code>npm install\n</code></pre></div>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-to-run-the-mocha-tests\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#to-run-the-mocha-tests\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>To run the mocha tests</h3>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"npm test\"><pre class=\"notranslate\"><code>npm test\n</code></pre></div>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-node-versions\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#node-versions\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Node versions</h3>\n<p dir=\"auto\">Nightmare is intended to be run on NodeJS 4.x or higher.</p>\n<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-api\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#api\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>API</h2>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-nightmareoptions\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#nightmareoptions\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Nightmare(options)</h4>\n<p dir=\"auto\">Creates a new instance that can navigate around the web. The available options are <a href=\"https://github.com/atom/electron/blob/master/docs/api/browser-window.md#new-browserwindowoptions\">documented here</a>, along with the following nightmare-specific options.</p>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-waittimeout-default-30s\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#waittimeout-default-30s\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>waitTimeout (default: 30s)</h5>\n<p dir=\"auto\">Throws an exception if the <code>.wait()</code> didn't return <code>true</code> within the set timeframe.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n waitTimeout: 1000 // in ms\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">waitTimeout</span>: <span class=\"pl-c1\">1000</span> <span class=\"pl-c\">// in ms</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-gototimeout-default-30s\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#gototimeout-default-30s\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>gotoTimeout (default: 30s)</h5>\n<p dir=\"auto\">Throws an exception if the <code>.goto()</code> didn't finish loading within the set timeframe. Note that, even though <code>goto</code> normally waits for all the resources on a page to load, a timeout exception is only raised if the DOM itself has not yet loaded.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n gotoTimeout: 1000 // in ms\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">gotoTimeout</span>: <span class=\"pl-c1\">1000</span> <span class=\"pl-c\">// in ms</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-loadtimeout-default-infinite\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#loadtimeout-default-infinite\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>loadTimeout (default: infinite)</h5>\n<p dir=\"auto\">Forces Nightmare to move on if a page transition caused by an action (eg, <code>.click()</code>) didn't finish within the set timeframe. If <code>loadTimeout</code> is shorter than <code>gotoTimeout</code>, the exceptions thrown by <code>gotoTimeout</code> will be suppressed.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n loadTimeout: 1000 // in ms\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">loadTimeout</span>: <span class=\"pl-c1\">1000</span> <span class=\"pl-c\">// in ms</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-executiontimeout-default-30s\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#executiontimeout-default-30s\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>executionTimeout (default: 30s)</h5>\n<p dir=\"auto\">The maximum amount of time to wait for an <code>.evaluate()</code> statement to complete.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n executionTimeout: 1000 // in ms\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">executionTimeout</span>: <span class=\"pl-c1\">1000</span> <span class=\"pl-c\">// in ms</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-paths\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#paths\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>paths</h5>\n<p dir=\"auto\">The default system paths that Electron knows about. Here's a list of available paths: <a href=\"https://github.com/atom/electron/blob/master/docs/api/app.md#appgetpathname\">https://github.com/atom/electron/blob/master/docs/api/app.md#appgetpathname</a></p>\n<p dir=\"auto\">You can overwrite them in Nightmare by doing the following:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n paths: {\n userData: '/user/data'\n }\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">paths</span>: <span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">userData</span>: <span class=\"pl-s\">'/user/data'</span>\n <span class=\"pl-kos\">}</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-switches\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#switches\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>switches</h5>\n<p dir=\"auto\">The command line switches used by the Chrome browser that are also supported by Electron. Here's a list of supported Chrome command line switches:\n<a href=\"https://github.com/atom/electron/blob/master/docs/api/chrome-command-line-switches.md\">https://github.com/atom/electron/blob/master/docs/api/chrome-command-line-switches.md</a></p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n switches: {\n 'proxy-server': '1.2.3.4:5678',\n 'ignore-certificate-errors': true\n }\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">switches</span>: <span class=\"pl-kos\">{</span>\n <span class=\"pl-s\">'proxy-server'</span>: <span class=\"pl-s\">'1.2.3.4:5678'</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-s\">'ignore-certificate-errors'</span>: <span class=\"pl-c1\">true</span>\n <span class=\"pl-kos\">}</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-electronpath\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#electronpath\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>electronPath</h5>\n<p dir=\"auto\">The path to the prebuilt Electron binary. This is useful for testing on different versions of Electron. Note that Nightmare only supports the version on which this package depends. Use this option at your own risk.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n electronPath: require('electron')\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">electronPath</span>: <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'electron'</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-dock-os-x\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#dock-os-x\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>dock (OS X)</h5>\n<p dir=\"auto\">A boolean to optionally show the Electron icon in the dock (defaults to <code>false</code>). This is useful for testing purposes.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n dock: true\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">dock</span>: <span class=\"pl-c1\">true</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-opendevtools\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#opendevtools\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>openDevTools</h5>\n<p dir=\"auto\">Optionally shows the DevTools in the Electron window using <code>true</code>, or use an object hash containing <code>mode: 'detach'</code> to show in a separate window. The hash gets passed to <a href=\"https://github.com/electron/electron/blob/master/docs/api/web-contents.md#contentsopendevtoolsoptions\"><code>contents.openDevTools()</code></a> to be handled. This is also useful for testing purposes. Note that this option is honored only if <code>show</code> is set to <code>true</code>.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n openDevTools: {\n mode: 'detach'\n },\n show: true\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">openDevTools</span>: <span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">mode</span>: <span class=\"pl-s\">'detach'</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c1\">show</span>: <span class=\"pl-c1\">true</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-typeinterval-default-100ms\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#typeinterval-default-100ms\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>typeInterval (default: 100ms)</h5>\n<p dir=\"auto\">How long to wait between keystrokes when using <code>.type()</code>.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n typeInterval: 20\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">typeInterval</span>: <span class=\"pl-c1\">20</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-pollinterval-default-250ms\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#pollinterval-default-250ms\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>pollInterval (default: 250ms)</h5>\n<p dir=\"auto\">How long to wait between checks for the <code>.wait()</code> condition to be successful.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n pollInterval: 50 //in ms\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">pollInterval</span>: <span class=\"pl-c1\">50</span> <span class=\"pl-c\">//in ms</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-maxauthretries-default-3\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#maxauthretries-default-3\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>maxAuthRetries (default: 3)</h5>\n<p dir=\"auto\">Defines the number of times to retry an authentication when set up with <code>.authenticate()</code>.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n maxAuthRetries: 3\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">maxAuthRetries</span>: <span class=\"pl-c1\">3</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-certificatesubjectname\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#certificatesubjectname\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>certificateSubjectName</h4>\n<p dir=\"auto\">A string to determine the client certificate selected by electron. If this options is set, the <a href=\"https://github.com/electron/electron/blob/master/docs/api/app.md#event-select-client-certificate\"><code>select-client-certificate</code></a> event will be set to loop through the certificateList and find the first certificate that matches <code>subjectName</code> on the electron <a href=\"https://electronjs.org/docs/api/structures/certificate\" rel=\"nofollow\"><code>Certificate Object</code></a>.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const nightmare = Nightmare({\n certificateSubjectName: 'tester'\n})\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">certificateSubjectName</span>: <span class=\"pl-s\">'tester'</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-engineversions\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#engineversions\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.engineVersions()</h4>\n<p dir=\"auto\">Gets the versions for Electron and Chromium.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-useragentuseragent\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#useragentuseragent\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.useragent(useragent)</h4>\n<p dir=\"auto\">Sets the <code>useragent</code> used by electron.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-authenticationuser-password\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#authenticationuser-password\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.authentication(user, password)</h4>\n<p dir=\"auto\">Sets the <code>user</code> and <code>password</code> for accessing a web page using basic authentication. Be sure to set it before calling <code>.goto(url)</code>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-end\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#end\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.end()</h4>\n<p dir=\"auto\">Completes any queue operations, disconnect and close the electron process. Note that if you're using promises, <code>.then()</code> must be called after <code>.end()</code> to run the <code>.end()</code> task. Also note that if using an <code>.end()</code> callback, the <code>.end()</code> call is equivalent to calling <code>.end()</code> followed by <code>.then(fn)</code>. Consider:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"nightmare\n .goto(someUrl)\n .end(() =&gt; 'some value')\n //prints &quot;some value&quot;\n .then(console.log)\"><pre><span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">someUrl</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">end</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-s\">'some value'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-c\">//prints \"some value\"</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">log</span><span class=\"pl-kos\">)</span></pre></div>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-halterror-done\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#halterror-done\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.halt(error, done)</h4>\n<p dir=\"auto\">Clears all queued operations, kills the electron process, and passes error message or 'Nightmare Halted' to an unresolved promise. Done will be called after the process has exited.</p>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-interact-with-the-page\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#interact-with-the-page\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Interact with the Page</h3>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-gotourl-headers\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#gotourl-headers\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.goto(url[, headers])</h4>\n<p dir=\"auto\">Loads the page at <code>url</code>. Optionally, a <code>headers</code> hash can be supplied to set headers on the <code>goto</code> request.</p>\n<p dir=\"auto\">When a page load is successful, <code>goto</code> returns an object with metadata about the page load, including:</p>\n<ul dir=\"auto\">\n<li><code>url</code>: The URL that was loaded</li>\n<li><code>code</code>: The HTTP status code (e.g. 200, 404, 500)</li>\n<li><code>method</code>: The HTTP method used (e.g. \"GET\", \"POST\")</li>\n<li><code>referrer</code>: The page that the window was displaying prior to this load or an empty string if this is the first page load.</li>\n<li><code>headers</code>: An object representing the response headers for the request as in <code>{header1-name: header1-value, header2-name: header2-value}</code></li>\n</ul>\n<p dir=\"auto\">If the page load fails, the error will be an object with the following properties:</p>\n<ul dir=\"auto\">\n<li><code>message</code>: A string describing the type of error</li>\n<li><code>code</code>: The underlying error code describing what went wrong. Note this is NOT the HTTP status code. For possible values, see <a href=\"https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h\" rel=\"nofollow\">https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h</a></li>\n<li><code>details</code>: A string with additional details about the error. This may be null or an empty string.</li>\n<li><code>url</code>: The URL that failed to load</li>\n</ul>\n<p dir=\"auto\">Note that any valid response from a server is considered “successful.” That means things like 404 “not found” errors are successful results for <code>goto</code>. Only things that would cause no page to appear in the browser window, such as no server responding at the given address, the server hanging up in the middle of a response, or invalid URLs, are errors.</p>\n<p dir=\"auto\">You can also adjust how long <code>goto</code> will wait before timing out by setting the <a href=\"#gototimeout-default-30s\"><code>gotoTimeout</code> option</a> on the Nightmare constructor.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-back\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#back\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.back()</h4>\n<p dir=\"auto\">Goes back to the previous page.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-forward\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#forward\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.forward()</h4>\n<p dir=\"auto\">Goes forward to the next page.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-refresh\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#refresh\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.refresh()</h4>\n<p dir=\"auto\">Refreshes the current page.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-clickselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#clickselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.click(selector)</h4>\n<p dir=\"auto\">Clicks the <code>selector</code> element once.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-mousedownselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#mousedownselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.mousedown(selector)</h4>\n<p dir=\"auto\">Mousedowns the <code>selector</code> element once.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-mouseupselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#mouseupselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.mouseup(selector)</h4>\n<p dir=\"auto\">Mouseups the <code>selector</code> element once.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-mouseoverselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#mouseoverselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.mouseover(selector)</h4>\n<p dir=\"auto\">Mouseovers the <code>selector</code> element once.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-mouseoutselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#mouseoutselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.mouseout(selector)</h4>\n<p dir=\"auto\">Mouseout the <code>selector</code> element once.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-typeselector-text\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#typeselector-text\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.type(selector[, text])</h4>\n<p dir=\"auto\">Enters the <code>text</code> provided into the <code>selector</code> element. Empty or falsey values provided for <code>text</code> will clear the selector's value.</p>\n<p dir=\"auto\"><code>.type()</code> mimics a user typing in a textbox and will emit the proper keyboard events.</p>\n<p dir=\"auto\">Key presses can also be fired using Unicode values with <code>.type()</code>. For example, if you wanted to fire an enter key press, you would write <code>.type('body', '\\u000d')</code>.</p>\n<blockquote>\n<p dir=\"auto\">If you don't need the keyboard events, consider using <code>.insert()</code> instead as it will be faster and more robust.</p>\n</blockquote>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-insertselector-text\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#insertselector-text\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.insert(selector[, text])</h4>\n<p dir=\"auto\">Similar to <code>.type()</code>, <code>.insert()</code> enters the <code>text</code> provided into the <code>selector</code> element. Empty or falsey values provided for <code>text</code> will clear the selector's value.</p>\n<p dir=\"auto\"><code>.insert()</code> is faster than <code>.type()</code> but does not trigger the keyboard events.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-checkselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#checkselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.check(selector)</h4>\n<p dir=\"auto\">Checks the <code>selector</code> checkbox element.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-uncheckselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#uncheckselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.uncheck(selector)</h4>\n<p dir=\"auto\">Unchecks the <code>selector</code> checkbox element.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-selectselector-option\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#selectselector-option\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.select(selector, option)</h4>\n<p dir=\"auto\">Changes the <code>selector</code> dropdown element to the option with attribute [value=<code>option</code>]</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-scrolltotop-left\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#scrolltotop-left\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.scrollTo(top, left)</h4>\n<p dir=\"auto\">Scrolls the page to desired position. <code>top</code> and <code>left</code> are always relative to the top left corner of the document.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-viewportwidth-height\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#viewportwidth-height\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.viewport(width, height)</h4>\n<p dir=\"auto\">Sets the viewport size.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-injecttype-file\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#injecttype-file\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.inject(type, file)</h4>\n<p dir=\"auto\">Injects a local <code>file</code> onto the current page. The file <code>type</code> must be either <code>js</code> or <code>css</code>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-evaluatefn-arg1-arg2\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#evaluatefn-arg1-arg2\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.evaluate(fn[, arg1, arg2,...])</h4>\n<p dir=\"auto\">Invokes <code>fn</code> on the page with <code>arg1, arg2,...</code>. All the <code>args</code> are optional. On completion it returns the return value of <code>fn</code>. Useful for extracting information from the page. Here's an example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const selector = 'h1'\nnightmare\n .evaluate(selector =&gt; {\n // now we're executing inside the browser scope.\n return document.querySelector(selector).innerText\n }, selector) // &lt;-- that's how you pass parameters from Node scope to browser scope\n .then(text =&gt; {\n // ...\n })\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">selector</span> <span class=\"pl-c1\">=</span> <span class=\"pl-s\">'h1'</span>\n<span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">selector</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// now we're executing inside the browser scope.</span>\n <span class=\"pl-k\">return</span> <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">querySelector</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">selector</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">innerText</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">selector</span><span class=\"pl-kos\">)</span> <span class=\"pl-c\">// &lt;-- that's how you pass parameters from Node scope to browser scope</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">text</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// ...</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">Error-first callbacks are supported as a part of <code>evaluate()</code>. If the arguments passed are one fewer than the arguments expected for the evaluated function, the evaluation will be passed a callback as the last parameter to the function. For example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const selector = 'h1'\nnightmare\n .evaluate((selector, done) =&gt; {\n // now we're executing inside the browser scope.\n setTimeout(\n () =&gt; done(null, document.querySelector(selector).innerText),\n 2000\n )\n }, selector)\n .then(text =&gt; {\n // ...\n })\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">selector</span> <span class=\"pl-c1\">=</span> <span class=\"pl-s\">'h1'</span>\n<span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">selector</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// now we're executing inside the browser scope.</span>\n <span class=\"pl-en\">setTimeout</span><span class=\"pl-kos\">(</span>\n <span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-s1\">done</span><span class=\"pl-kos\">(</span><span class=\"pl-c1\">null</span><span class=\"pl-kos\">,</span> <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">querySelector</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">selector</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">innerText</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c1\">2000</span>\n <span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">selector</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">text</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// ...</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">Note that callbacks support only one value argument (eg <code>function(err, value)</code>). Ultimately, the callback will get wrapped in a native Promise and only be able to resolve a single value.</p>\n<p dir=\"auto\">Promises are also supported as a part of <code>evaluate()</code>. If the return value of the function has a <code>then</code> member, <code>.evaluate()</code> assumes it is waiting for a promise. For example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const selector = 'h1';\nnightmare\n .evaluate((selector) =&gt; (\n new Promise((resolve, reject) =&gt; {\n setTimeout(() =&gt; resolve(document.querySelector(selector).innerText), 2000);\n )}, selector)\n )\n .then((text) =&gt; {\n // ...\n })\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">selector</span> <span class=\"pl-c1\">=</span> <span class=\"pl-s\">'h1'</span><span class=\"pl-kos\">;</span>\n<span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-c1\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">selector</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">(</span>\n <span class=\"pl-k\">new</span> <span class=\"pl-v\">Promise</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">resolve</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">reject</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-en\">setTimeout</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-s1\">resolve</span><span class=\"pl-kos\">(</span><span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">querySelector</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">selector</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">innerText</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">,</span> <span class=\"pl-c1\">2000</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">)</span><span class=\"pl-kos\">}</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">selector</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">text</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// ...</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-waitms\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#waitms\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.wait(ms)</h4>\n<p dir=\"auto\">Waits for <code>ms</code> milliseconds e.g. <code>.wait(5000)</code>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-waitselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#waitselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.wait(selector)</h4>\n<p dir=\"auto\">Waits until the element <code>selector</code> is present e.g. <code>.wait('#pay-button')</code>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-waitfn-arg1-arg2\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#waitfn-arg1-arg2\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.wait(fn[, arg1, arg2,...])</h4>\n<p dir=\"auto\">Waits until the <code>fn</code> evaluated on the page with <code>arg1, arg2,...</code> returns <code>true</code>. All the <code>args</code> are optional. See <code>.evaluate()</code> for usage.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-headerheader-value\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#headerheader-value\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.header(header, value)</h4>\n<p dir=\"auto\">Adds a header override for all HTTP requests. If <code>header</code> is undefined, the header overrides will be reset.</p>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-extract-from-the-page\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#extract-from-the-page\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Extract from the Page</h3>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-existsselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#existsselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.exists(selector)</h4>\n<p dir=\"auto\">Returns whether the selector exists or not on the page.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-visibleselector\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#visibleselector\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.visible(selector)</h4>\n<p dir=\"auto\">Returns whether the selector is visible or not.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-onevent-callback\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#onevent-callback\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.on(event, callback)</h4>\n<p dir=\"auto\">Captures page events with the callback. You have to call <code>.on()</code> before calling <code>.goto()</code>. Supported events are <a href=\"http://electron.atom.io/docs/api/web-contents/#class-webcontents\" rel=\"nofollow\">documented here</a>.</p>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-additional-page-events\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#additional-page-events\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Additional \"page\" events</h5>\n<h6 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-onpage-functiontypeerror-message-stack\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#onpage-functiontypeerror-message-stack\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.on('page', function(type=\"error\", message, stack))</h6>\n<p dir=\"auto\">This event is triggered if any javascript exception is thrown on the page. But this event is not triggered if the injected javascript code (e.g. via <code>.evaluate()</code>) is throwing an exception.</p>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-page-events\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#page-events\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>\"page\" events</h5>\n<p dir=\"auto\">Listens for <code>window.addEventListener('error')</code>, <code>alert(...)</code>, <code>prompt(...)</code> &amp; <code>confirm(...)</code>.</p>\n<h6 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-onpage-functiontypeerror-message-stack-1\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#onpage-functiontypeerror-message-stack-1\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.on('page', function(type=\"error\", message, stack))</h6>\n<p dir=\"auto\">Listens for top-level page errors. This will get triggered when an error is thrown on the page.</p>\n<h6 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-onpage-functiontypealert-message\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#onpage-functiontypealert-message\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.on('page', function(type=\"alert\", message))</h6>\n<p dir=\"auto\">Nightmare disables <code>window.alert</code> from popping up by default, but you can still listen for the contents of the alert dialog.</p>\n<h6 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-onpage-functiontypeprompt-message-response\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#onpage-functiontypeprompt-message-response\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.on('page', function(type=\"prompt\", message, response))</h6>\n<p dir=\"auto\">Nightmare disables <code>window.prompt</code> from popping up by default, but you can still listen for the message to come up. If you need to handle the confirmation differently, you'll need to use your own preload script.</p>\n<h6 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-onpage-functiontypeconfirm-message-response\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#onpage-functiontypeconfirm-message-response\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.on('page', function(type=\"confirm\", message, response))</h6>\n<p dir=\"auto\">Nightmare disables <code>window.confirm</code> from popping up by default, but you can still listen for the message to come up. If you need to handle the confirmation differently, you'll need to use your own preload script.</p>\n<h6 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-onconsole-functiontype--arguments-\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#onconsole-functiontype--arguments-\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.on('console', function(type [, arguments, ...]))</h6>\n<p dir=\"auto\"><code>type</code> will be either <code>log</code>, <code>warn</code> or <code>error</code> and <code>arguments</code> are what gets passed from the console. This event is not triggered if the injected javascript code (e.g. via <code>.evaluate()</code>) is using <code>console.log</code>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-onceevent-callback\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#onceevent-callback\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.once(event, callback)</h4>\n<p dir=\"auto\">Similar to <code>.on()</code>, but captures page events with the callback one time.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-removelistenerevent-callback\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#removelistenerevent-callback\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.removeListener(event, callback)</h4>\n<p dir=\"auto\">Removes a given listener callback for an event.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-screenshotpath-clip\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#screenshotpath-clip\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.screenshot([path][, clip])</h4>\n<p dir=\"auto\">Takes a screenshot of the current page. Useful for debugging. The output is always a <code>png</code>. Both arguments are optional. If <code>path</code> is provided, it saves the image to the disk. Otherwise it returns a <code>Buffer</code> of the image data. If <code>clip</code> is provided (as <a href=\"https://github.com/atom/electron/blob/master/docs/api/browser-window.md#wincapturepagerect-callback\">documented here</a>), the image will be clipped to the rectangle.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-htmlpath-savetype\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#htmlpath-savetype\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.html(path, saveType)</h4>\n<p dir=\"auto\">Saves the current page as html as files to disk at the given path. Save type options are <a href=\"https://github.com/atom/electron/blob/master/docs/api/web-contents.md#webcontentssavepagefullpath-savetype-callback\">here</a>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-pdfpath-options\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#pdfpath-options\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.pdf(path, options)</h4>\n<p dir=\"auto\">Saves a PDF to the specified <code>path</code>. Options are <a href=\"https://github.com/electron/electron/blob/v1.4.4/docs/api/web-contents.md#contentsprinttopdfoptions-callback\">here</a>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-title\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#title\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.title()</h4>\n<p dir=\"auto\">Returns the title of the current page.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-url\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#url\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.url()</h4>\n<p dir=\"auto\">Returns the url of the current page.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-path\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#path\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.path()</h4>\n<p dir=\"auto\">Returns the path name of the current page.</p>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookies\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookies\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Cookies</h3>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookiesgetname\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookiesgetname\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.cookies.get(name)</h4>\n<p dir=\"auto\">Gets a cookie by it's <code>name</code>. The url will be the current url.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookiesgetquery\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookiesgetquery\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.cookies.get(query)</h4>\n<p dir=\"auto\">Queries multiple cookies with the <code>query</code> object. If a <code>query.name</code> is set, it will return the first cookie it finds with that name, otherwise it will query for an array of cookies. If no <code>query.url</code> is set, it will use the current url. Here's an example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"// get all google cookies that are secure\n// and have the path `/query`\nnightmare\n .goto('http://google.com')\n .cookies.get({\n path: '/query',\n secure: true\n })\n .then(cookies =&gt; {\n // do something with the cookies\n })\"><pre><span class=\"pl-c\">// get all google cookies that are secure</span>\n<span class=\"pl-c\">// and have the path `/query`</span>\n<span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://google.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-c1\">cookies</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">get</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">path</span>: <span class=\"pl-s\">'/query'</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c1\">secure</span>: <span class=\"pl-c1\">true</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">cookies</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// do something with the cookies</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">Available properties are documented here: <a href=\"https://github.com/atom/electron/blob/master/docs/api/session.md#sescookiesgetdetails-callback\">https://github.com/atom/electron/blob/master/docs/api/session.md#sescookiesgetdetails-callback</a></p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookiesget\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookiesget\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.cookies.get()</h4>\n<p dir=\"auto\">Gets all the cookies for the current url. If you'd like get all cookies for all urls, use: <code>.get({ url: null })</code>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookiessetname-value\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookiessetname-value\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.cookies.set(name, value)</h4>\n<p dir=\"auto\">Sets a cookie's <code>name</code> and <code>value</code>. This is the most basic form, and the url will be the current url.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookiessetcookie\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookiessetcookie\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.cookies.set(cookie)</h4>\n<p dir=\"auto\">Sets a <code>cookie</code>. If <code>cookie.url</code> is not set, it will set the cookie on the current url. Here's an example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"nightmare\n .goto('http://google.com')\n .cookies.set({\n name: 'token',\n value: 'some token',\n path: '/query',\n secure: true\n })\n // ... other actions ...\n .then(() =&gt; {\n // ...\n })\"><pre><span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://google.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-c1\">cookies</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">set</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">name</span>: <span class=\"pl-s\">'token'</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c1\">value</span>: <span class=\"pl-s\">'some token'</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c1\">path</span>: <span class=\"pl-s\">'/query'</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c1\">secure</span>: <span class=\"pl-c1\">true</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-c\">// ... other actions ...</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// ...</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">Available properties are documented here: <a href=\"https://github.com/atom/electron/blob/master/docs/api/session.md#sescookiessetdetails-callback\">https://github.com/atom/electron/blob/master/docs/api/session.md#sescookiessetdetails-callback</a></p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookiessetcookies\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookiessetcookies\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.cookies.set(cookies)</h4>\n<p dir=\"auto\">Sets multiple cookies at once. <code>cookies</code> is an array of <code>cookie</code> objects. Take a look at the <code>.cookies.set(cookie)</code> documentation above for a better idea of what <code>cookie</code> should look like.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookiesclearname\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookiesclearname\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.cookies.clear([name])</h4>\n<p dir=\"auto\">Clears a cookie for the current domain. If <code>name</code> is not specified, all cookies for the current domain will be cleared.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"nightmare\n .goto('http://google.com')\n .cookies.clear('SomeCookieName')\n // ... other actions ...\n .then(() =&gt; {\n // ...\n })\"><pre><span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://google.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-c1\">cookies</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">clear</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'SomeCookieName'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-c\">// ... other actions ...</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// ...</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-cookiesclearall\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#cookiesclearall\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.cookies.clearAll()</h4>\n<p dir=\"auto\">Clears all cookies for all domains.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"nightmare\n .goto('http://google.com')\n .cookies.clearAll()\n // ... other actions ...\n .then(() =&gt; {\n //...\n })\"><pre><span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://google.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-c1\">cookies</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">clearAll</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-c\">// ... other actions ...</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">//...</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-proxies\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#proxies\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Proxies</h3>\n<p dir=\"auto\">Proxies are supported in Nightmare through <a href=\"#switches\">switches</a>.</p>\n<p dir=\"auto\">If your proxy requires authentication you also need the <a href=\"#authenticationuser-password\">authentication</a> call.</p>\n<p dir=\"auto\">The following example not only demonstrates how to use proxies, but you can run it to test if your proxy connection is working:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import Nightmare from 'nightmare';\n\nconst proxyNightmare = Nightmare({\n switches: {\n 'proxy-server': 'my_proxy_server.example.com:8080' // set the proxy server here ...\n },\n show: true\n});\n\nproxyNightmare\n .authentication('proxyUsername', 'proxyPassword') // ... and authenticate here before `goto`\n .goto('http://www.ipchicken.com')\n .evaluate(() =&gt; {\n return document.querySelector('b').innerText.replace(/[^\\d\\.]/g, '');\n })\n .end()\n .then((ip) =&gt; { // This will log the Proxy's IP\n console.log('proxy IP:', ip);\n });\n\n// The rest is just normal Nightmare to get your local IP\nconst regularNightmare = Nightmare({ show: true });\n\nregularNightmare\n .goto('http://www.ipchicken.com')\n .evaluate(() =&gt;\n document.querySelector('b').innerText.replace(/[^\\d\\.]/g, '');\n )\n .end()\n .then((ip) =&gt; { // This will log the your local IP\n console.log('local IP:', ip);\n });\"><pre><span class=\"pl-k\">import</span> <span class=\"pl-v\">Nightmare</span> <span class=\"pl-k\">from</span> <span class=\"pl-s\">'nightmare'</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-k\">const</span> <span class=\"pl-s1\">proxyNightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">switches</span>: <span class=\"pl-kos\">{</span>\n <span class=\"pl-s\">'proxy-server'</span>: <span class=\"pl-s\">'my_proxy_server.example.com:8080'</span> <span class=\"pl-c\">// set the proxy server here ...</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c1\">show</span>: <span class=\"pl-c1\">true</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-s1\">proxyNightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">authentication</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'proxyUsername'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s\">'proxyPassword'</span><span class=\"pl-kos\">)</span> <span class=\"pl-c\">// ... and authenticate here before `goto`</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://www.ipchicken.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-k\">return</span> <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">querySelector</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'b'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">innerText</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">replace</span><span class=\"pl-kos\">(</span><span class=\"pl-pds\"><span class=\"pl-c1\">/</span><span class=\"pl-kos\">[</span>^<span class=\"pl-cce\">\\d</span><span class=\"pl-cce\">\\.</span><span class=\"pl-kos\">]</span><span class=\"pl-c1\">/</span>g</span><span class=\"pl-kos\">,</span> <span class=\"pl-s\">''</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">end</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">ip</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span> <span class=\"pl-c\">// This will log the Proxy's IP</span>\n <span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">log</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'proxy IP:'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">ip</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-c\">// The rest is just normal Nightmare to get your local IP</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-s1\">regularNightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span> <span class=\"pl-c1\">show</span>: <span class=\"pl-c1\">true</span> <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-s1\">regularNightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://www.ipchicken.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span>\n <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">querySelector</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'b'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">innerText</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">replace</span><span class=\"pl-kos\">(</span><span class=\"pl-pds\"><span class=\"pl-c1\">/</span><span class=\"pl-kos\">[</span>^<span class=\"pl-cce\">\\d</span><span class=\"pl-cce\">\\.</span><span class=\"pl-kos\">]</span><span class=\"pl-c1\">/</span>g</span><span class=\"pl-kos\">,</span> <span class=\"pl-s\">''</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">end</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">ip</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span> <span class=\"pl-c\">// This will log the your local IP</span>\n <span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">log</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'local IP:'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">ip</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span></pre></div>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-promises\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#promises\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Promises</h3>\n<p dir=\"auto\">By default, Nightmare uses default native ES6 promises. You can plug in your favorite <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise\" rel=\"nofollow\">ES6-style promises library</a> like <a href=\"https://www.npmjs.com/package/bluebird\" rel=\"nofollow\">bluebird</a> or <a href=\"https://www.npmjs.com/package/q\" rel=\"nofollow\">q</a> for convenience!</p>\n<p dir=\"auto\">Here's an example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"var Nightmare = require('nightmare')\n\nNightmare.Promise = require('bluebird')\n// OR:\nNightmare.Promise = require('q').Promise\"><pre><span class=\"pl-k\">var</span> <span class=\"pl-v\">Nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'nightmare'</span><span class=\"pl-kos\">)</span>\n\n<span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">Promise</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'bluebird'</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-c\">// OR:</span>\n<span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">Promise</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'q'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">Promise</span></pre></div>\n<p dir=\"auto\">You can also specify a custom Promise library per-instance with the <code>Promise</code> constructor option like so:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"var Nightmare = require('nightmare')\n\nvar es6Nightmare = Nightmare()\nvar bluebirdNightmare = Nightmare({\n Promise: require('bluebird')\n})\n\nvar es6Promise = es6Nightmare\n .goto('https://github.com/segmentio/nightmare')\n .then()\nvar bluebirdPromise = bluebirdNightmare\n .goto('https://github.com/segmentio/nightmare')\n .then()\n\nes6Promise.isFulfilled() // throws: `TypeError: es6EndPromise.isFulfilled is not a function`\nbluebirdPromise.isFulfilled() // returns: `true | false`\"><pre><span class=\"pl-k\">var</span> <span class=\"pl-v\">Nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'nightmare'</span><span class=\"pl-kos\">)</span>\n\n<span class=\"pl-k\">var</span> <span class=\"pl-s1\">es6Nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-k\">var</span> <span class=\"pl-s1\">bluebirdNightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">Promise</span>: <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'bluebird'</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n\n<span class=\"pl-k\">var</span> <span class=\"pl-s1\">es6Promise</span> <span class=\"pl-c1\">=</span> <span class=\"pl-s1\">es6Nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'https://github.com/segmentio/nightmare'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-k\">var</span> <span class=\"pl-s1\">bluebirdPromise</span> <span class=\"pl-c1\">=</span> <span class=\"pl-s1\">bluebirdNightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'https://github.com/segmentio/nightmare'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n\n<span class=\"pl-s1\">es6Promise</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">isFulfilled</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c\">// throws: `TypeError: es6EndPromise.isFulfilled is not a function`</span>\n<span class=\"pl-s1\">bluebirdPromise</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">isFulfilled</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c\">// returns: `true | false`</span></pre></div>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-extending-nightmare\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#extending-nightmare\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Extending Nightmare</h3>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-nightmareactionname-electronactionelectronnamespace-actionnamespace\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#nightmareactionname-electronactionelectronnamespace-actionnamespace\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Nightmare.action(name, [electronAction|electronNamespace], action|namespace)</h4>\n<p dir=\"auto\">You can add your own custom actions to the Nightmare prototype. Here's an example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"Nightmare.action('size', function(done) {\n this.evaluate_now(() =&gt; {\n const w = Math.max(\n document.documentElement.clientWidth,\n window.innerWidth || 0\n )\n const h = Math.max(\n document.documentElement.clientHeight,\n window.innerHeight || 0\n )\n return {\n height: h,\n width: w\n }\n }, done)\n})\n\nNightmare()\n .goto('http://cnn.com')\n .size()\n .then(size =&gt; {\n //... do something with the size information\n })\"><pre><span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">action</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'size'</span><span class=\"pl-kos\">,</span> <span class=\"pl-k\">function</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">this</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate_now</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-k\">const</span> <span class=\"pl-s1\">w</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Math</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">max</span><span class=\"pl-kos\">(</span>\n <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">documentElement</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">clientWidth</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-smi\">window</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">innerWidth</span> <span class=\"pl-c1\">||</span> <span class=\"pl-c1\">0</span>\n <span class=\"pl-kos\">)</span>\n <span class=\"pl-k\">const</span> <span class=\"pl-s1\">h</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Math</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">max</span><span class=\"pl-kos\">(</span>\n <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">documentElement</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">clientHeight</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-smi\">window</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">innerHeight</span> <span class=\"pl-c1\">||</span> <span class=\"pl-c1\">0</span>\n <span class=\"pl-kos\">)</span>\n <span class=\"pl-k\">return</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">height</span>: <span class=\"pl-s1\">h</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c1\">width</span>: <span class=\"pl-s1\">w</span>\n <span class=\"pl-kos\">}</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n\n<span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://cnn.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">size</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">size</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">//... do something with the size information</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<blockquote>\n<p dir=\"auto\">Remember, this is attached to the static class <code>Nightmare</code>, not the instance.</p>\n</blockquote>\n<p dir=\"auto\">You'll notice we used an internal function <code>evaluate_now</code>. This function is different than <code>nightmare.evaluate</code> because it runs it immediately, whereas <code>nightmare.evaluate</code> is queued.</p>\n<p dir=\"auto\">An easy way to remember: when in doubt, use <code>evaluate</code>. If you're creating custom actions, use <code>evaluate_now</code>. The technical reason is that since our action has already been queued and we're running it now, we shouldn't re-queue the evaluate function.</p>\n<p dir=\"auto\">We can also create custom namespaces. We do this internally for <code>nightmare.cookies.get</code> and <code>nightmare.cookies.set</code>. These are useful if you have a bundle of actions you want to expose, but it will clutter up the main nightmare object. Here's an example of that:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"Nightmare.action('style', {\n background(done) {\n this.evaluate_now(\n () =&gt; window.getComputedStyle(document.body, null).backgroundColor,\n done\n )\n }\n})\n\nNightmare()\n .goto('http://google.com')\n .style.background()\n .then(background =&gt; {\n // ... do something interesting with background\n })\"><pre><span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">action</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'style'</span><span class=\"pl-kos\">,</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-en\">background</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">this</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate_now</span><span class=\"pl-kos\">(</span>\n <span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-smi\">window</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">getComputedStyle</span><span class=\"pl-kos\">(</span><span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">body</span><span class=\"pl-kos\">,</span> <span class=\"pl-c1\">null</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">backgroundColor</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-s1\">done</span>\n <span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">}</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n\n<span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://google.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-c1\">style</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">background</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">background</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// ... do something interesting with background</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">You can also add custom Electron actions. The additional Electron action or namespace actions take <code>name</code>, <code>options</code>, <code>parent</code>, <code>win</code>, <code>renderer</code>, and <code>done</code>. Note the Electron action comes first, mirroring how <code>.evaluate()</code> works. For example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"Nightmare.action(\n 'clearCache',\n (name, options, parent, win, renderer, done) =&gt; {\n parent.respondTo('clearCache', done =&gt; {\n win.webContents.session.clearCache(done)\n })\n done()\n },\n function(done) {\n this.child.call('clearCache', done)\n }\n)\n\nNightmare()\n .clearCache()\n .goto('http://example.org')\n //... more actions ...\n .then(() =&gt; {\n // ...\n })\"><pre><span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">action</span><span class=\"pl-kos\">(</span>\n <span class=\"pl-s\">'clearCache'</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-kos\">(</span><span class=\"pl-s1\">name</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">options</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">parent</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">win</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">renderer</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-s1\">parent</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">respondTo</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'clearCache'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">done</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-s1\">win</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">webContents</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">session</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">clearCache</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-s1\">done</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-k\">function</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">this</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">child</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">call</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'clearCache'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s1\">done</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">}</span>\n<span class=\"pl-kos\">)</span>\n\n<span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">clearCache</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://example.org'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-c\">//... more actions ...</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// ...</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">...would clear the browser’s cache before navigating to <code>example.org</code>.</p>\n<p dir=\"auto\">See <a href=\"https://github.com/rosshinkley/nightmare-examples/blob/master/docs/beginner/action.md\">this document</a> for more details on creating custom actions.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-useplugin\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#useplugin\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>.use(plugin)</h4>\n<p dir=\"auto\"><code>nightmare.use</code> is useful for reusing a set of tasks on an instance. Check out <a href=\"https://github.com/segmentio/nightmare-swiftly\">nightmare-swiftly</a> for some examples.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-custom-preload-script\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#custom-preload-script\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Custom preload script</h4>\n<p dir=\"auto\">If you need to do something custom when you first load the window environment, you\ncan specify a custom preload script. Here's how you do that:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import path from 'path'\n\nconst nightmare = Nightmare({\n webPreferences: {\n preload: path.resolve('custom-script.js')\n //alternative: preload: &quot;absolute/path/to/custom-script.js&quot;\n }\n})\"><pre><span class=\"pl-k\">import</span> <span class=\"pl-s1\">path</span> <span class=\"pl-k\">from</span> <span class=\"pl-s\">'path'</span>\n\n<span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">webPreferences</span>: <span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">preload</span>: <span class=\"pl-s1\">path</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">resolve</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'custom-script.js'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-c\">//alternative: preload: \"absolute/path/to/custom-script.js\"</span>\n <span class=\"pl-kos\">}</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">The only requirement for that script is that you'll need the following prelude:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"window.__nightmare = {}\n__nightmare.ipc = require('electron').ipcRenderer\"><pre><span class=\"pl-smi\">window</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">__nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-kos\">{</span><span class=\"pl-kos\">}</span>\n<span class=\"pl-s1\">__nightmare</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">ipc</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'electron'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">ipcRenderer</span></pre></div>\n<p dir=\"auto\">To benefit of all of nightmare's feedback from the browser, you can instead copy the contents of nightmare's <a href=\"/segment-boneyard/nightmare/blob/master/lib/preload.js\">preload script</a>.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-storage-persistence-between-nightmare-instances\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#storage-persistence-between-nightmare-instances\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Storage Persistence between nightmare instances</h4>\n<p dir=\"auto\">By default nightmare will create an in-memory partition for each instance. This means that any localStorage or cookies or any other form of persistent state will be destroyed when nightmare is ended. If you would like to persist state between instances you can use the <a href=\"http://electron.atom.io/docs/api/browser-window/#new-browserwindowoptions\" rel=\"nofollow\">webPreferences.partition</a> api in electron.</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import Nightmare from 'nightmare';\n\nnightmare = Nightmare(); // non persistent paritition by default\nyield nightmare\n .evaluate(() =&gt; {\n window.localStorage.setItem('testing', 'This will not be persisted');\n })\n .end();\n\nnightmare = Nightmare({\n webPreferences: {\n partition: 'persist: testing'\n }\n});\nyield nightmare\n .evaluate(() =&gt; {\n window.localStorage.setItem('testing', 'This is persisted for other instances with the same paritition name');\n })\n .end();\"><pre><span class=\"pl-k\">import</span> <span class=\"pl-v\">Nightmare</span> <span class=\"pl-k\">from</span> <span class=\"pl-s\">'nightmare'</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span> <span class=\"pl-c\">// non persistent paritition by default</span>\n<span class=\"pl-k\">yield</span> <span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">window</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">localStorage</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">setItem</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'testing'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s\">'This will not be persisted'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">end</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">webPreferences</span>: <span class=\"pl-kos\">{</span>\n <span class=\"pl-c1\">partition</span>: <span class=\"pl-s\">'persist: testing'</span>\n <span class=\"pl-kos\">}</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n<span class=\"pl-k\">yield</span> <span class=\"pl-s1\">nightmare</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">window</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">localStorage</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">setItem</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'testing'</span><span class=\"pl-kos\">,</span> <span class=\"pl-s\">'This is persisted for other instances with the same paritition name'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">end</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span></pre></div>\n<p dir=\"auto\">If you specify a <code>null</code> paritition then it will use the electron default behavior (persistent) or any string that starts with <code>'persist:'</code> will persist under that partition name, any other string will result in in-memory only storage.</p>\n<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-usage\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#usage\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Usage</h2>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-installation\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#installation\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Installation</h4>\n<p dir=\"auto\">Nightmare is a Node.js module, so you'll need to <a href=\"http://nodejs.org/\" rel=\"nofollow\">have Node.js installed</a>. Then you just need to <code>npm install</code> the module:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"$ npm install --save nightmare\"><pre>$ npm install --save nightmare</pre></div>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-execution\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#execution\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Execution</h4>\n<p dir=\"auto\">Nightmare is a node module that can be used in a Node.js script or module. Here's a simple script to open a web page:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import Nightmare from 'nightmare';\n\nconst nightmare = Nightmare();\n\nnightmare.goto('http://cnn.com')\n .evaluate(() =&gt; {\n return document.title;\n })\n .end()\n .then((title) =&gt; {\n console.log(title);\n })\"><pre><span class=\"pl-k\">import</span> <span class=\"pl-v\">Nightmare</span> <span class=\"pl-k\">from</span> <span class=\"pl-s\">'nightmare'</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-k\">const</span> <span class=\"pl-s1\">nightmare</span> <span class=\"pl-c1\">=</span> <span class=\"pl-v\">Nightmare</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-s1\">nightmare</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">goto</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'http://cnn.com'</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">evaluate</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-k\">return</span> <span class=\"pl-smi\">document</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">title</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">end</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">.</span><span class=\"pl-en\">then</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">title</span><span class=\"pl-kos\">)</span> <span class=\"pl-c1\">=&gt;</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">log</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">title</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span></pre></div>\n<p dir=\"auto\">If you save this as <code>cnn.js</code>, you can run it on the command line like this:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm install --save nightmare\nnode cnn.js\"><pre>npm install --save nightmare\nnode cnn.js</pre></div>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-common-execution-problems\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#common-execution-problems\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Common Execution Problems</h4>\n<p dir=\"auto\">Nightmare heavily relies on <a href=\"http://electron.atom.io/\" rel=\"nofollow\">Electron</a> for heavy lifting. And Electron in turn relies on several UI-focused dependencies (eg. libgtk+) which are often missing from server distros.</p>\n<p dir=\"auto\">For help running nightmare on your server distro check out <a href=\"https://gist.github.com/dimkir/f4afde77366ff041b66d2252b45a13db\">How to run nightmare on Amazon Linux and CentOS</a> guide.</p>\n<h4 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-debugging\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#debugging\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Debugging</h4>\n<p dir=\"auto\">There are three good ways to get more information about what's happening inside the headless browser:</p>\n<ol dir=\"auto\">\n<li>Use the <code>DEBUG=*</code> flag described below.</li>\n<li>Pass <code>{ show: true }</code> to the <a href=\"#nightmareoptions\">nightmare constructor</a> to have it create a visible, rendered window where you can watch what is happening.</li>\n<li>Listen for <a href=\"#onevent-callback\">specific events</a>.</li>\n</ol>\n<p dir=\"auto\">To run the same file with debugging output, run it like this <code>DEBUG=nightmare node cnn.js</code> (on Windows use <code>set DEBUG=nightmare &amp; node cnn.js</code>).</p>\n<p dir=\"auto\">This will print out some additional information about what's going on:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"nightmare queueing action &quot;goto&quot; +0ms\nnightmare queueing action &quot;evaluate&quot; +4ms\nBreaking News, U.S., World, Weather, Entertainment &amp; Video News - CNN.com\"><pre>nightmare queueing action <span class=\"pl-s\"><span class=\"pl-pds\">\"</span>goto<span class=\"pl-pds\">\"</span></span> +0ms\nnightmare queueing action <span class=\"pl-s\"><span class=\"pl-pds\">\"</span>evaluate<span class=\"pl-pds\">\"</span></span> +4ms\nBreaking News, U.S., World, Weather, Entertainment <span class=\"pl-k\">&amp;</span> Video News - CNN.com</pre></div>\n<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-debug-flags\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#debug-flags\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Debug Flags</h5>\n<p dir=\"auto\">All nightmare messages</p>\n<p dir=\"auto\"><code>DEBUG=nightmare*</code></p>\n<p dir=\"auto\">Only actions</p>\n<p dir=\"auto\"><code>DEBUG=nightmare:actions*</code></p>\n<p dir=\"auto\">Only logs</p>\n<p dir=\"auto\"><code>DEBUG=nightmare:log*</code></p>\n<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-additional-resources\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#additional-resources\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Additional Resources</h2>\n<ul dir=\"auto\">\n<li>\n<p dir=\"auto\"><a href=\"https://github.com/rosshinkley/nightmare-examples\">Ross Hinkley's Nightmare Examples</a> is a great resource for setting up nightmare, learning about custom actions, and avoiding common pitfalls.</p>\n</li>\n<li>\n<p dir=\"auto\"><a href=\"https://github.com/matthewmueller/nightmare-issues\">Nightmare Issues</a> has a bunch of standalone runnable examples. The script numbers correspond to nightmare issue numbers.</p>\n</li>\n<li>\n<p dir=\"auto\"><a href=\"https://hackernoon.com/nightmarishly-good-scraping-with-nightmare-js-and-async-await-b7b20a38438f\" rel=\"nofollow\">Nightmarishly good scraping</a> is a great tutorial by <a href=\"https://twitter.com/@aendrew\" rel=\"nofollow\">Ændrew Rininsland</a> on getting up &amp; running with Nightmare using real-life data.</p>\n</li>\n</ul>\n<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-tests\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#tests\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>Tests</h2>\n<p dir=\"auto\">Automated tests for nightmare itself are run using <a href=\"http://mochajs.org/\" rel=\"nofollow\">Mocha</a> and Chai, both of which will be installed via <code>npm install</code>. To run nightmare's tests, just run <code>make test</code>.</p>\n<p dir=\"auto\">When the tests are done, you'll see something like this:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"make test\n ․․․․․․․․․․․․․․․․․․\n 18 passing (1m)\"><pre>make <span class=\"pl-c1\">test</span>\n ․․․․․․․․․․․․․․․․․․\n 18 passing (1m)</pre></div>\n<p dir=\"auto\">Note that if you are using <code>xvfb</code>, <code>make test</code> will automatically run the tests under an <code>xvfb-run</code> wrapper. If you are planning to run the tests headlessly without running <code>xvfb</code> first, set the <code>HEADLESS</code> environment variable to <code>0</code>.</p>\n<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-license-mit\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" href=\"#license-mit\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a>License (MIT)</h2>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"WWWWWW||WWWWWW\n W W W||W W W\n ||\n ( OO )__________\n / | \\\n /o o| MIT \\\n \\___/||_||__||_|| *\n || || || ||\n _||_|| _||_||\n (__|__|(__|__|\"><pre class=\"notranslate\"><code>WWWWWW||WWWWWW\n W W W||W W W\n ||\n ( OO )__________\n / | \\\n /o o| MIT \\\n \\___/||_||__||_|| *\n || || || ||\n _||_|| _||_||\n (__|__|(__|__|\n</code></pre></div>\n<p dir=\"auto\">Copyright (c) 2015 Segment.io, Inc. <a href=\"mailto:[email protected]\">mailto:[email protected]</a></p>\n<p dir=\"auto\">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:</p>\n<p dir=\"auto\">The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>\n<p dir=\"auto\">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.</p>\n</article>",
"loaded": true,
"timedOut": false,
"errorMessage": null,
"headerInfo": {
"toc": [
{
"level": 1,
"text": "Nightmare",
"anchor": "nightmare",
"htmlText": "Nightmare"
},
{
"level": 2,
"text": "Examples",
"anchor": "examples",
"htmlText": "Examples"
},
{
"level": 3,
"text": "To install dependencies",
"anchor": "to-install-dependencies",
"htmlText": "To install dependencies"
},
{
"level": 3,
"text": "To run the mocha tests",
"anchor": "to-run-the-mocha-tests",
"htmlText": "To run the mocha tests"
},
{
"level": 3,
"text": "Node versions",
"anchor": "node-versions",
"htmlText": "Node versions"
},
{
"level": 2,
"text": "API",
"anchor": "api",
"htmlText": "API"
},
{
"level": 4,
"text": "Nightmare(options)",
"anchor": "nightmareoptions",
"htmlText": "Nightmare(options)"
},
{
"level": 5,
"text": "waitTimeout (default: 30s)",
"anchor": "waittimeout-default-30s",
"htmlText": "waitTimeout (default: 30s)"
},
{
"level": 5,
"text": "gotoTimeout (default: 30s)",
"anchor": "gototimeout-default-30s",
"htmlText": "gotoTimeout (default: 30s)"
},
{
"level": 5,
"text": "loadTimeout (default: infinite)",
"anchor": "loadtimeout-default-infinite",
"htmlText": "loadTimeout (default: infinite)"
},
{
"level": 5,
"text": "executionTimeout (default: 30s)",
"anchor": "executiontimeout-default-30s",
"htmlText": "executionTimeout (default: 30s)"
},
{
"level": 5,
"text": "paths",
"anchor": "paths",
"htmlText": "paths"
},
{
"level": 5,
"text": "switches",
"anchor": "switches",
"htmlText": "switches"
},
{
"level": 5,
"text": "electronPath",
"anchor": "electronpath",
"htmlText": "electronPath"
},
{
"level": 5,
"text": "dock (OS X)",
"anchor": "dock-os-x",
"htmlText": "dock (OS X)"
},
{
"level": 5,
"text": "openDevTools",
"anchor": "opendevtools",
"htmlText": "openDevTools"
},
{
"level": 5,
"text": "typeInterval (default: 100ms)",
"anchor": "typeinterval-default-100ms",
"htmlText": "typeInterval (default: 100ms)"
},
{
"level": 5,
"text": "pollInterval (default: 250ms)",
"anchor": "pollinterval-default-250ms",
"htmlText": "pollInterval (default: 250ms)"
},
{
"level": 5,
"text": "maxAuthRetries (default: 3)",
"anchor": "maxauthretries-default-3",
"htmlText": "maxAuthRetries (default: 3)"
},
{
"level": 4,
"text": "certificateSubjectName",
"anchor": "certificatesubjectname",
"htmlText": "certificateSubjectName"
},
{
"level": 4,
"text": ".engineVersions()",
"anchor": "engineversions",
"htmlText": ".engineVersions()"
},
{
"level": 4,
"text": ".useragent(useragent)",
"anchor": "useragentuseragent",
"htmlText": ".useragent(useragent)"
},
{
"level": 4,
"text": ".authentication(user, password)",
"anchor": "authenticationuser-password",
"htmlText": ".authentication(user, password)"
},
{
"level": 4,
"text": ".end()",
"anchor": "end",
"htmlText": ".end()"
},
{
"level": 4,
"text": ".halt(error, done)",
"anchor": "halterror-done",
"htmlText": ".halt(error, done)"
},
{
"level": 3,
"text": "Interact with the Page",
"anchor": "interact-with-the-page",
"htmlText": "Interact with the Page"
},
{
"level": 4,
"text": ".goto(url[, headers])",
"anchor": "gotourl-headers",
"htmlText": ".goto(url[, headers])"
},
{
"level": 4,
"text": ".back()",
"anchor": "back",
"htmlText": ".back()"
},
{
"level": 4,
"text": ".forward()",
"anchor": "forward",
"htmlText": ".forward()"
},
{
"level": 4,
"text": ".refresh()",
"anchor": "refresh",
"htmlText": ".refresh()"
},
{
"level": 4,
"text": ".click(selector)",
"anchor": "clickselector",
"htmlText": ".click(selector)"
},
{
"level": 4,
"text": ".mousedown(selector)",
"anchor": "mousedownselector",
"htmlText": ".mousedown(selector)"
},
{
"level": 4,
"text": ".mouseup(selector)",
"anchor": "mouseupselector",
"htmlText": ".mouseup(selector)"
},
{
"level": 4,
"text": ".mouseover(selector)",
"anchor": "mouseoverselector",
"htmlText": ".mouseover(selector)"
},
{
"level": 4,
"text": ".mouseout(selector)",
"anchor": "mouseoutselector",
"htmlText": ".mouseout(selector)"
},
{
"level": 4,
"text": ".type(selector[, text])",
"anchor": "typeselector-text",
"htmlText": ".type(selector[, text])"
},
{
"level": 4,
"text": ".insert(selector[, text])",
"anchor": "insertselector-text",
"htmlText": ".insert(selector[, text])"
},
{
"level": 4,
"text": ".check(selector)",
"anchor": "checkselector",
"htmlText": ".check(selector)"
},
{
"level": 4,
"text": ".uncheck(selector)",
"anchor": "uncheckselector",
"htmlText": ".uncheck(selector)"
},
{
"level": 4,
"text": ".select(selector, option)",
"anchor": "selectselector-option",
"htmlText": ".select(selector, option)"
},
{
"level": 4,
"text": ".scrollTo(top, left)",
"anchor": "scrolltotop-left",
"htmlText": ".scrollTo(top, left)"
},
{
"level": 4,
"text": ".viewport(width, height)",
"anchor": "viewportwidth-height",
"htmlText": ".viewport(width, height)"
},
{
"level": 4,
"text": ".inject(type, file)",
"anchor": "injecttype-file",
"htmlText": ".inject(type, file)"
},
{
"level": 4,
"text": ".evaluate(fn[, arg1, arg2,...])",
"anchor": "evaluatefn-arg1-arg2",
"htmlText": ".evaluate(fn[, arg1, arg2,...])"
},
{
"level": 4,
"text": ".wait(ms)",
"anchor": "waitms",
"htmlText": ".wait(ms)"
},
{
"level": 4,
"text": ".wait(selector)",
"anchor": "waitselector",
"htmlText": ".wait(selector)"
},
{
"level": 4,
"text": ".wait(fn[, arg1, arg2,...])",
"anchor": "waitfn-arg1-arg2",
"htmlText": ".wait(fn[, arg1, arg2,...])"
},
{
"level": 4,
"text": ".header(header, value)",
"anchor": "headerheader-value",
"htmlText": ".header(header, value)"
},
{
"level": 3,
"text": "Extract from the Page",
"anchor": "extract-from-the-page",
"htmlText": "Extract from the Page"
},
{
"level": 4,
"text": ".exists(selector)",
"anchor": "existsselector",
"htmlText": ".exists(selector)"
},
{
"level": 4,
"text": ".visible(selector)",
"anchor": "visibleselector",
"htmlText": ".visible(selector)"
},
{
"level": 4,
"text": ".on(event, callback)",
"anchor": "onevent-callback",
"htmlText": ".on(event, callback)"
},
{
"level": 5,
"text": "Additional \"page\" events",
"anchor": "additional-page-events",
"htmlText": "Additional \"page\" events"
},
{
"level": 6,
"text": ".on('page', function(type=\"error\", message, stack))",
"anchor": "onpage-functiontypeerror-message-stack",
"htmlText": ".on('page', function(type=\"error\", message, stack))"
},
{
"level": 5,
"text": "\"page\" events",
"anchor": "page-events",
"htmlText": "\"page\" events"
},
{
"level": 6,
"text": ".on('page', function(type=\"error\", message, stack))",
"anchor": "onpage-functiontypeerror-message-stack-1",
"htmlText": ".on('page', function(type=\"error\", message, stack))"
},
{
"level": 6,
"text": ".on('page', function(type=\"alert\", message))",
"anchor": "onpage-functiontypealert-message",
"htmlText": ".on('page', function(type=\"alert\", message))"
},
{
"level": 6,
"text": ".on('page', function(type=\"prompt\", message, response))",
"anchor": "onpage-functiontypeprompt-message-response",
"htmlText": ".on('page', function(type=\"prompt\", message, response))"
},
{
"level": 6,
"text": ".on('page', function(type=\"confirm\", message, response))",
"anchor": "onpage-functiontypeconfirm-message-response",
"htmlText": ".on('page', function(type=\"confirm\", message, response))"
},
{
"level": 6,
"text": ".on('console', function(type [, arguments, ...]))",
"anchor": "onconsole-functiontype--arguments-",
"htmlText": ".on('console', function(type [, arguments, ...]))"
},
{
"level": 4,
"text": ".once(event, callback)",
"anchor": "onceevent-callback",
"htmlText": ".once(event, callback)"
},
{
"level": 4,
"text": ".removeListener(event, callback)",
"anchor": "removelistenerevent-callback",
"htmlText": ".removeListener(event, callback)"
},
{
"level": 4,
"text": ".screenshot([path][, clip])",
"anchor": "screenshotpath-clip",
"htmlText": ".screenshot([path][, clip])"
},
{
"level": 4,
"text": ".html(path, saveType)",
"anchor": "htmlpath-savetype",
"htmlText": ".html(path, saveType)"
},
{
"level": 4,
"text": ".pdf(path, options)",
"anchor": "pdfpath-options",
"htmlText": ".pdf(path, options)"
},
{
"level": 4,
"text": ".title()",
"anchor": "title",
"htmlText": ".title()"
},
{
"level": 4,
"text": ".url()",
"anchor": "url",
"htmlText": ".url()"
},
{
"level": 4,
"text": ".path()",
"anchor": "path",
"htmlText": ".path()"
},
{
"level": 3,
"text": "Cookies",
"anchor": "cookies",
"htmlText": "Cookies"
},
{
"level": 4,
"text": ".cookies.get(name)",
"anchor": "cookiesgetname",
"htmlText": ".cookies.get(name)"
},
{
"level": 4,
"text": ".cookies.get(query)",
"anchor": "cookiesgetquery",
"htmlText": ".cookies.get(query)"
},
{
"level": 4,
"text": ".cookies.get()",
"anchor": "cookiesget",
"htmlText": ".cookies.get()"
},
{
"level": 4,
"text": ".cookies.set(name, value)",
"anchor": "cookiessetname-value",
"htmlText": ".cookies.set(name, value)"
},
{
"level": 4,
"text": ".cookies.set(cookie)",
"anchor": "cookiessetcookie",
"htmlText": ".cookies.set(cookie)"
},
{
"level": 4,
"text": ".cookies.set(cookies)",
"anchor": "cookiessetcookies",
"htmlText": ".cookies.set(cookies)"
},
{
"level": 4,
"text": ".cookies.clear([name])",
"anchor": "cookiesclearname",
"htmlText": ".cookies.clear([name])"
},
{
"level": 4,
"text": ".cookies.clearAll()",
"anchor": "cookiesclearall",
"htmlText": ".cookies.clearAll()"
},
{
"level": 3,
"text": "Proxies",
"anchor": "proxies",
"htmlText": "Proxies"
},
{
"level": 3,
"text": "Promises",
"anchor": "promises",
"htmlText": "Promises"
},
{
"level": 3,
"text": "Extending Nightmare",
"anchor": "extending-nightmare",
"htmlText": "Extending Nightmare"
},
{
"level": 4,
"text": "Nightmare.action(name, [electronAction|electronNamespace], action|namespace)",
"anchor": "nightmareactionname-electronactionelectronnamespace-actionnamespace",
"htmlText": "Nightmare.action(name, [electronAction|electronNamespace], action|namespace)"
},
{
"level": 4,
"text": ".use(plugin)",
"anchor": "useplugin",
"htmlText": ".use(plugin)"
},
{
"level": 4,
"text": "Custom preload script",
"anchor": "custom-preload-script",
"htmlText": "Custom preload script"
},
{
"level": 4,
"text": "Storage Persistence between nightmare instances",
"anchor": "storage-persistence-between-nightmare-instances",
"htmlText": "Storage Persistence between nightmare instances"
},
{
"level": 2,
"text": "Usage",
"anchor": "usage",
"htmlText": "Usage"
},
{
"level": 4,
"text": "Installation",
"anchor": "installation",
"htmlText": "Installation"
},
{
"level": 4,
"text": "Execution",
"anchor": "execution",
"htmlText": "Execution"
},
{
"level": 4,
"text": "Common Execution Problems",
"anchor": "common-execution-problems",
"htmlText": "Common Execution Problems"
},
{
"level": 4,
"text": "Debugging",
"anchor": "debugging",
"htmlText": "Debugging"
},
{
"level": 5,
"text": "Debug Flags",
"anchor": "debug-flags",
"htmlText": "Debug Flags"
},
{
"level": 2,
"text": "Additional Resources",
"anchor": "additional-resources",
"htmlText": "Additional Resources"
},
{
"level": 2,
"text": "Tests",
"anchor": "tests",
"htmlText": "Tests"
},
{
"level": 2,
"text": "License (MIT)",
"anchor": "license-mit",
"htmlText": "License (MIT)"
}
],
"siteNavLoginPath": "/login?return_to=https%3A%2F%2Fgithub.com%2Fsegment-boneyard%2Fnightmare"
}
}
],
"overviewFilesProcessingTime": 66.993092
}
},
"appPayload": {
"helpUrl": "https://docs.github.com",
"findFileWorkerPath": "/assets-cdn/worker/find-file-worker-32bb159cc57c.js",
"findInFileWorkerPath": "/assets-cdn/worker/find-in-file-worker-c6704d501c10.js",
"githubDevUrl": null,
"enabled_features": {
"code_nav_ui_events": false,
"copilot_conversational_ux": false,
"copilot_conversational_ux_embedding_update": false,
"copilot_popover_file_editor_header": false,
"copilot_smell_icebreaker_ux": true,
"copilot_workspace": false,
"codeview_firefox_inert": true
}
}
}
}
{
"accept-ranges": "bytes",
"cache-control": "max-age=0, private, must-revalidate",
"content-encoding": "gzip",
"content-security-policy": "default-src 'none'; base-uri 'self'; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com api.githubcopilot.com objects-origin.githubusercontent.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/",
"content-type": "text/html; charset=utf-8",
"date": "Mon, 26 Feb 2024 10:20:28 GMT",
"etag": "7f73db05f487a5c863ad92e0538817ff",
"referrer-policy": "no-referrer-when-downgrade",
"server": "GitHub.com",
"set-cookie": "logged_in=no; Path=/; Domain=github.com; Expires=Wed, 26 Feb 2025 10:20:28 GMT; HttpOnly; Secure; SameSite=Lax",
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
"transfer-encoding": "chunked",
"vary": "X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, Accept-Encoding, Accept, X-Requested-With",
"x-content-type-options": "nosniff",
"x-frame-options": "deny",
"x-github-request-id": "D214:533E:33BB0E9:49149A5:65DC65D3",
"x-xss-protection": "0"
}