A
A
alex__882016-06-13 15:33:05
JavaScript
alex__88, 2016-06-13 15:33:05

How to run simple example nightmarejs on c9.io server. How to do it?

I am creating a workspace. I connect modules npm install nightmare and blah blah. I am running node app.js.

var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: false });

nightmare
  .goto('http://yahoo.com')
  .screenshot('public/shot.png')
  .type('form[action*="/search"] [name=p]', 'github nightmare')
  .click('form[action*="/search"] [type=submit]')
  .wait('#main')
  .evaluate(function () {
    return document.querySelector('#main .searchCenterMiddle li a').href
  })
  .end()
  .then(function (result) {
    console.log(result)
  })
  .catch(function (error) {
    console.error('Search failed:', error);
  });
  console.log('run nightmare')

But it doesn't return or do anything. Perhaps additional settings are needed or something else. What I do not know. Perhaps there is a tutorial

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex__88, 2016-06-15
@alex__88

Should have done the following

apt-get -y update
apt-get -y upgrade
apt-get -y --force-yes install make unzip g++ libssl-dev git xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps clang libdbus-1-dev libgtk2.0-dev libnotify-dev libgnome-keyring-dev libgconf2-dev libasound2-dev libcap-dev libcups2-dev libxtst-dev libxss1 libnss3-dev gcc-multilib g++-multilib

and run like this
xvfb-run node --harmony app.js

A
Anatoly, 2016-06-13
@taliban

I don't really know how nightmare works but every example has yeld at the beginning.
Even if without it even the console log does not work for you, then yeld itself implies the presence of generators that appeared in the node like in version 4, so first of all check the version of the node, I think that you will have version 0.12 or so.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question