3

I try to run my test.js file below with the command:

 DEBUG=nightmare node --harmony test.js 

and taking output:

 nightmare queueing action "goto" for http://google.com +0ms
 nightmare queueing action "wait" +2ms
 nightmare queueing action "screenshot" +0ms

test.js:

 var Nightmare = require('nightmare');

 var google = new Nightmare()
    .goto('http://google.com')
    .wait()
    .screenshot("./screen.png")
    .run(function(err, nightmare) {
        if (err) return console.log(err);
            console.log('Done!');
    });

No screenshot and link access. Is there any idea?

note: i am working on Virtual Box with Linux Guest.

Leo
  • 665
  • 2
  • 9
  • 25
RedArrow
  • 588
  • 8
  • 18

1 Answers1

1

Try with:

var google = new Nightmare({ show: true })

You will be able to see if the link is opening or not.

For Debug try using the below instead:

DEBUG=nightmare:actions node --harmony test.js

This will show you that the code is throwing error like in your case:

nightmare:actions Not enough arguments for .wait()

.wait() requires either a time interval or a function returning true or a dom element.

Try something like:

.wait(2000) // For 2 sec wait
.wait("input[type='text'][title='Search']") // To wait till the search box is loaded
.wait( () => {
    // Check Something
    return true
})

Please check if the above helps is resolving your issue.

  • unfortunately, even though i applied those steps, still i see the same results. i have found a link ; discussing similar case [https://github.com/segmentio/nightmare/issues/142](https://github.com/segmentio/nightmare/issues/142). I think there is a crucial problem with the phantomjs or other libraries?!. It does not matter how large number that i enter to the .wait() function, it passes with 0ms. – RedArrow Nov 19 '15 at 21:58
  • I tried your code snippet on my Linux and it worked perfectly fine. The only hiccup was the wait() section. Anyways, hope it would have helped. Will try to dig deeper. – Aditya Jhunjhunwala Nov 20 '15 at 03:26
  • thanks aditya, i think i have problems with the versions of phantomjs or nodejs. i agree with you that your snippets should work as far as i have seen from the different examples on the web. I use Centos and is there any recommandation for nightmarejs installation that you apply. – RedArrow Nov 20 '15 at 08:04