nightmare-wait-for-url
v1.0.0
Published
Extends Nightmare with .waitForUrl() action.
Downloads
239
Maintainers
Readme
nightmare-wait-for-url
Adds .waitForUrl() to your Nightmare scripts.
tl;dr
- Install by executing
npm install nightmare-wait-for-url
oryarn add nightmare-wait-for-url
. - Import by adding
require('nightmare-wait-for-url')
. - Use by adding
.waitForUrl(url)
to your Nightmare chain, whereurl
is aString
or aRegExp
.
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 [email protected] who created its initial version. Thank you!