Lurker News

Comments (70) 33 threads

tucosan2 replies#
Even after substituting the fancy ampersands on your homepage, and requiring nightmare your example still does not run:

  var Nightmare = require('nightmare');
  new Nightmare()
    .goto('http://yahoo.com')
    .type('input[title="Search"]', 'github nightmare')
    .click('.searchsubmit')
    .run();
yields:

  node yahoo.js
  phantom stdout: TypeError: 'null' is not an object (evaluating 'element.value = text')


  phantom stdout:   phantomjs://webpage.evaluate():3
    phantomjs://webpage.evaluate():4
    phantomjs://webpage.evaluate():4

  stream.js:94
        throw er; // Unhandled stream error in pipe.
              ^
  TypeError: undefined is not a function
      at next (/private/tmp/night/node_modules/nightmare/lib/index.js:56:23)
      at f (/private/tmp/night/node_modules/nightmare/node_modules/once/once.js:16:25)
      at Proto.apply (/private/tmp/night/node_modules/nightmare/node_modules/phantom/node_modules/dnode/node_modules/dnode-protocol/index.js:123:13)
      at Proto.handle (/private/tmp/night/node_modules/nightmare/node_modules/phantom/node_modules/dnode/node_modules/dnode-protocol/index.js:99:19)
      at D.dnode.handle (/private/tmp/night/node_modules/nightmare/node_modules/phantom/node_modules/dnode/lib/dnode.js:140:21)
      at D.dnode.write (/private/tmp/night/node_modules/nightmare/node_modules/phantom/node_modules/dnode/lib/dnode.js:128:22)
      at SockJSConnection.ondata (stream.js:51:26)
      at SockJSConnection.EventEmitter.emit (events.js:107:17)
      at Session.didMessage (/private/tmp/night/node_modules/nightmare/node_modules/phantom/node_modules/shoe/node_modules/sockjs/lib/transport.js:220:25)
      at WebSocketReceiver.didMessage (/private/tmp/night/node_modules/nightmare/node_modules/phantom/node_modules/shoe/node_modules/sockjs/lib/trans-websocket.js:102:40)
The examples in the githubs pages readme don't run either. I am too lazy to debug this.
resu_nimda#
I got it to run by providing a callback to the 'run' function: run(function(){ console.log('done'); });

By default there is no indication of completion, hence the log.

pkrein1 reply#
hey sorry about that, just realized i forgot to npm publish v1.1.0 -- published now hope that helps
pkrein3 replies#
Quick example of how we use this at Segment... for each integration (https://segment.io/integrations) we need to create a vector logo. This got a bit tedious after the first 50 :) so we built nightmare + nightmare-swiftly so that our chat bot could "auto-generate" vector logos: https://cloudup.com/cEA-dTd3glM

Hope it's helpful!

bennyg1 reply#
Is it doing this by checking colored pixel areas and making SVG shapes for them? If so, whatever you use should replace Illustrator's Image Trace functionality, cause that is so bad at creating crisp vector copies of things.
aarondf2 replies#
Looks like they are submitting it to Swiftly, and then a human does it.
pkrein#
yep this
bennyg#
:( - I was hoping for a cool algorithm to determine that. Haha maybe I'll write one.
baudehlo#
Please note that because you used the base "phantom" library from npm it won't ever work with cluster (because node doesn't do the right thing with port=0 under cluster).

You'd have to switch to node-phantom-simple. Which might be worthwhile anyway because the phantom library you've used proved massively unstable at scale for us - I wrote it because of the need to work under cluster, and because dnode communication was bloated and unstable.

dhotson#
Hey Peter,

Swiftly lead dev here. Just wanted to say this is very cool! I was a little bit surprised to see us in your examples.
We've been looking into improving our end-to-end testing tools, but it looks like you guys have already taken care of it. Nice work! ;-)

ssharp1 reply#
Could I accomplish multi-page form automation doing something like:

  .goto(page1)
    // page 1
    .type('selector', 'value')
    .click('selector')
    .wait()

    // page 2
    .type('selector', 'value')
    .click('selector')
    .wait()
etc. ?

If so, that seems super easy and more straightforward than vanilla Shadow or even Casper.

pkrein1 reply#
that's exactly right
ssharp#
Thanks, this should be absolutely perfect for a project I've been procrastinating on :)
resu_nimda2 replies#
I've been wanting to programmatically get my transaction details from my bank for a while. I knew about phantomJS but never got around to trying it out. When I saw this I decided to give it a shot, and within half an hour I was able to log into my bank's website (a complicated multi-step process that I had failed to achieve with just POST requests).

Nice tool, thanks. The debugging could use a bit of work - whenever something went wrong it just spit out a bunch of "null is not an object" messages from phantom. Overall it was very easy to use though.

Lord_Zero1 reply#
Whats a good way to automate this to run? I see the getting started in the documentation says "Save it as hello.js and then run it from the command line" but Iwasnt sure if there are tools like CRON in Linux to automate the script.
resu_nimda#
That is the documentation for phantomjs, which is a stand-alone process. Nightmare is a package for nodejs (that interacts with a phantomjs process), so your code runs in a node context, where there are plenty of scheduling options, e.g. the node-cron package, or just plain setInterval().
montecarl#
I really want to do this with the two accounts I have at different banks. Neither makes it easy to automatically download my transactions. What I want is to run a command to run to download the latest transactions and output some simple ledger-like[1] output.

When I have tried to do double entry account before it was tricky to keep up. I would spent a lot of time trying to figure out what I had already reconciled and what I had not.
1: http://www.ledger-cli.org/

Load more comments