Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nightmare-wait-for-url

wojtekmaj320MIT1.0.0

Extends Nightmare with .waitForUrl() action.

nightmare, phantomjs, nightmarejs, waitForUrl

readme

downloads build dependencies dev dependencies tested with jest

nightmare-wait-for-url

Adds .waitForUrl() to your Nightmare scripts.

tl;dr

  • Install by executing npm install nightmare-wait-for-url or yarn add nightmare-wait-for-url.
  • Import by adding require('nightmare-wait-for-url').
  • Use by adding .waitForUrl(url) to your Nightmare chain, where url is a String or a RegExp.

Getting started

Installation

Add nigthmare-wait-for-url by executing npm install nightmare-wait-for-url or yarn add nightmare-wait-for-url.

Usage

Here's an example of basic usage:

const Nightmare = require('nightmare');
require('nightmare-wait-for-url');

const nightmare = Nightmare({ show: true })

nightmare
  .goto('https://duckduckgo.com/')
  .type('#search_form_input_homepage', 'Alexander the great')
  .click('#search_button_homepage')
  .waitForUrl('https://duckduckgo.com/?q=Alexander+the+great');

.waitForUrl(string)

Waits for the navigation to include the provided string.

Example:

nightmare
  .goto('https://duckduckgo.com/')
  .type('#search_form_input_homepage', 'Alexander the great')
  .click('#search_button_homepage')
  .waitForUrl('https://duckduckgo.com/?q=Alexander+the+great');

.waitForUrl(regex)

Waits for the navigation to match the provided regular expression.

Example:

nightmare
  .goto('https://duckduckgo.com/')
  .type('#search_form_input_homepage', 'Alexander the great')
  .click('#search_button_homepage')
  .waitForUrl(/(Alexander|Hamster)\+the\+great/);

waitTimeout

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

More on waitTimeout in Nightmare's README.

License

The MIT License.

Author

Alexander Liljengård
alexander@paxxmedia.se
Wojciech Maj
kontakt@wojtekmaj.pl
http://wojtekmaj.pl

Thank you

This project wouldn't be possible without awesome work of Alexander Liljengård alexander@paxxmedia.se who created its initial version. Thank you!