# nightmare-iframe-manager

> delegates commands to iframes in Nightmare

Latest version **0.0.4** (published 2016-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install nightmare-iframe-manager
pnpm add nightmare-iframe-manager
yarn add nightmare-iframe-manager
bun add nightmare-iframe-manager
```

## 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.0.4 |
| Published | 2016-11-04 |
| First published | 2016-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Ross Hinkley |
| Maintainers | faranta, rosshinkley |
| Keywords | nightmare, phantomjs, iframe, iframes |

## Links

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

## Dependencies (1)

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

## Recent versions

- 0.0.4 (latest) — 2016-11-04
- 0.0.2 — 2016-08-04

## README

nightmare-iframe-manager
========================

Add inline iframe management to your [Nightmare](http://github.com/segmentio/nightmare) scripts.

## Credit
Original idea was thanks to @tiangolo in [segmentio/nightmare#496](https://github.com/segmentio/nightmare/pull/496).

# _WARNING_
This plugin overrides Nightmare's internal `evaluate_now` method to wrap the page's `document` variable.  This is dangerous and fragile.  After entering an iframe, certain functionality may not work as expected.  Read the pull in the credit link for more information.  _You have been warned._

## Usage
Require the library, passing the Nightmare constructor as a parameter: 

```js
var Nightmare = require('nightmare');
require('nightmare-iframe-manager')(Nightmare);
```

... and that's it.  You should now be able to enter and exit iframes.

### .enterIFrame(selector)
Enter an iframe with the given selector.  All subsequent requests will go through that iframe until `.exitIFrame()` or `.resetFrame()` is called.

### .exitIFrame()
Exits the current selector to the previous one.  If exiting the last selector, this exits to the root document.

### .resetFrame()
Resets all frames and restores the root document.

## Example

```javascript
var Nightmare = require('nightmare');
require('nightmare-iframe-manager')(Nightmare);
var nightmare = Nightmare();
nightmare.goto('http://example.com')
  .enterIFrame('#someIFrame')
  .title()
  .then(function(title){
    // `title` is the title of the child frame #someIFrame
  })
```

## Common Issues
### Blocked iFrame Cross-Origin Communication
```javascript
var nightmare = Nightmare({
  show:true,
  webPreferences: {
    webSecurity:false
    }
  })
```
When webSecurity is set to false, it will disable the same-origin policy (usually using testing websites by people), and set allowDisplayingInsecureContent and allowRunningInsecureContent to true if these two options are not set by user. Default is true.

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