1.0.0 • Published 6 years ago

nightmare-wait-for-url v1.0.0

Weekly downloads
169
License
MIT
Repository
github
Last release
6 years ago

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

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!