These are chat archives for rosshinkley/nightmare

17th
Apr 2017
Vladimir Milenko
@VladimirMilenko
Apr 17 2017 18:11
Hi guys!
Can someone help me? I want to keep nightmare running forever :D
johnferro
@johnferro
Apr 17 2017 19:19
@VladimirMilenko I believe the electron process will stay up until you call end on it. Not sure if that's helpful but probably need more information about your particular use case to give more details
Vladimir Milenko
@VladimirMilenko
Apr 17 2017 19:20
@johnferro I need to launch some page which connects via WS to some server and makes tons of screenshots. So what i need - is to keep nightmare process alive
Now looks like i've solved by calling wait with 0 ms, but without calling end. So it throws unhandled promise, but stays alive
johnferro
@johnferro
Apr 17 2017 19:42
@VladimirMilenko Ok, glad you found something that works for you. For future reference I don't think the wait is strictly required. For example, if you run the following script you should see the electron window remain open until the node process is explicitly killed.
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true});

nightmare
  .goto('https://duckduckgo.com')
  .type('#search_form_input_homepage', 'github nightmare')
  .click('#search_button_homepage')
  .wait('#zero_click_wrapper .c-info__title a')
  .evaluate(function () {
    return document.querySelector('#zero_click_wrapper .c-info__title a').href;
  })
  //.end()
  .then(function (result) {
    console.log(result);
  })
  .catch(function (error) {
    console.error('Search failed:', error);
  });