Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Allows Nightmare to execute delayed returns via a callback mechanism without using yeild

License

Notifications You must be signed in to change notification settings

concur/nightmare-evaluate-with-callback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nightmare-evaluate-with-callback

Adds evaluateWithCallback action to Nightmare. This will allow you to execute asynchronous code in the Nightmare's browser context and halt the evaluation chain until it returns.

Primitive arguments passed to the callback function will be fed to the next action in the chain, similar to calling return 'value'; in Nightmare's built in evaluate action.

Install

$ npm install nightmare-evaluate-with-callback

Usage

var Nightmare = require('nightmare');
require('nightmare-evaluate-with-callback')(Nightmare);

var nightmare = Nightmare();

nightmare
  .goto('http://google.com')
  .evaluateWithCallback(function (callback) {
    setTimeout(function() {
      callback(document.location.href);
    }, 1000);
  })
  .end()
  .then(function (result) {
    console.log(result)
  })
  .catch(function (error) {
    console.error('Failed:', error);
  });

About

Allows Nightmare to execute delayed returns via a callback mechanism without using yeild

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published