nightmare-wait-for-url

1.0.0 • Public • Published

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!

Package Sidebar

Install

npm i nightmare-wait-for-url

Weekly Downloads

43

Version

1.0.0

License

MIT

Unpacked Size

11.4 kB

Total Files

10

Last publish

Collaborators

  • zn4rk