Show HN: Nightmare – Simple browser automation
nightmarejs.org
nightmarejs.org
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.By default there is no indication of completion, hence the log.
https://github.com/ianmiell/shutit/blob/master/library/night...
which should help matters. Will reply when done.
Hope it's helpful!
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.
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! ;-)
.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.
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.
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.
Browser automation? Is this a test suite of some sort, something like selenium? Or is it more like Mechanize?
Their website has some serious style. It looks cool and original. Which raises a meta-issue that has been bugging me for a while. This is the bar you have to meet for even an open source project nowadays. It's not enough for you to pour your blood sweat and tears into something and then give it away for free. You then have to create slick looking site to market it and get people's attention.
I think most of the people don't care about the fab wrap, as long as the product works properly.
nightmare.js:1
Should there be more instructions for installing? I believe the brew command is something for Mac users only...With Selenium you have full cross browser support, while Phantom is Webkit based.
Can you please provide an example for using `evaluate()` to get the page's content?
I tried this, but didn't get anything:
new Nightmare()
.goto('http://yahoo.com')
.evaluate(function (page) { return this.content; }, function (res) {console.log(res);})
.run();https://github.com/andrey-p/ectoplasm-js
Pardon the shameless plug.
- phantom.create({ port: port }, function(instance) {
+ phantom.create({ port: port}, "--ssl-protocol=X", function(instance) {I'm getting about:blank everytime I hit a web address using ssl.
Please don't use fancy quotes or the fancy apostrophe for code examples on your webpage. It looks out-of-place with the rest of the fixed width font and, most importantly, it stops folks from being able to copy-and-paste your examples into their terminal or editor.
What I mean is that PhantomJS engine still falls short of a real browser. Advantage of running a real browser with Xvfb is that you won't ever have to worry about if the page is going to render properly or have it behave the way you expect it to. The overhead is not of a big deal, in fact it's a tradeoff for rendering accuracy.
Don't get me wrong headless browser like PhantomJS is headed in the right direction but if compatibility with website is crucial for your success, it is not enough and I just don't have a lot of confidence that it will replace a real browser with Xvfb.
Basically the Javascript libraries are reinventing a lot of the wheels that have already been done in other languages before the explosion of Node.js.
Maybe you'd be able to run more instances with PhantomJS compared to running Xvfb and a real browser because of lower memory consumption. I don't know if this is true.