# nightmare-upload

> upload files using NightmareJS

Latest version **0.1.1** (published 2016-05-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install nightmare-upload
pnpm add nightmare-upload
yarn add nightmare-upload
bun add nightmare-upload
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2016-05-22 |
| First published | 2016-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ross Hinkley |
| Maintainers | rosshinkley |
| Keywords | nightmare, upload |

## Links

- npm: https://www.npmjs.com/package/nightmare-upload
- Repository: https://github.com/rosshinkley/nightmare-upload
- Homepage: https://github.com/rosshinkley/nightmare-upload#readme
- Issues: https://github.com/rosshinkley/nightmare-upload/issues
- npm.io page: https://npm.io/package/nightmare-upload

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^2.2.0

## Recent versions

- 0.1.1 (latest) — 2016-05-22
- 0.1.0 — 2016-05-22

## README

# nightmare-upload
Grants the ability to add files to file inputs for Nightmare 2.x, just like the good ol' days of Nightmare 1.x.

## Usage
Require the library, passing Nightmare as a reference to add the plugin actions:

```js
var Nightmare = require('nightmare');
require('nightmare-upload')(Nightmare);
```
### .upload(selector, files)
Specify the `files` to add to a `selector` file input.  The `files` parameter can be a single string (for a single file) or an array of strings (for multiple files).

## Important note about setting file upload inputs
This plugin will not work if the Chromium devtools panel is open as Chromium allows only one attachment to the debugger at a time.

## Example

```js
var Nightmare = require('nightmare');
require('nightmare-upload')(Nightmare);
var nightmare = Nightmare();
nightmare
 .goto('http://some-url.tld')
 .upload('#some_file_input', '/path/to/my/upload.ext')
 .click('#button_that_submits_form_for_upload')
 ...
```

## References/Credits

  * @Zn4rk for [bringing this method to my attention](https://github.com/segmentio/nightmare/issues/235#issuecomment-214226205)
  * @svbatalov for the [original implementation](https://github.com/electron/electron/issues/749#issuecomment-213822739)

---
_Source: https://npm.io/package/nightmare-upload · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
