Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login
Nightwatch.js (nightwatchjs.org) similar stories update story
235 points by Lazare | karma 17347 | avg karma 7.67 2014-01-31 05:02:54 | hide | past | favorite | 50 comments



view as:

Or Rembrandt paintings?

In fact they specifically say

Nightwatch got its name from the famous painting The Night Watch by Dutch painter Rembrandt van Rijn. The masterpiece is prominently displayed in the Rijksmuseum, in Amsterdam - The Netherlands.

http://nightwatchjs.org/guide


What other names have you used then?

what benefit does it have in comparison to casperjs?

casper works with phantomjs. nightwatch works with selenium.

Thank you for introducing me to phantomjs, just the thing I need.

If you like phantom, check out casper. It makes phantom much easier to use

This uses Selenium WebDrivers so that you can run your tests against actual browsers (instead of PhantomJS). Notably this means that you can run your tests in IE

Also, this is Node.js compatible - CasperJS is not.

whatever casperjs is as compatible with nodejs as this stuff.This stuff uses selenium,it's not a stand alone solution.

How is it any different from wd.js?

This looks nice, but there are a lot of sugar libraries over the webdriver protocol, its the smallest part of the problem of real browser testing but it has lots of solutions, the real problems have almost 0 choice.

What I really want is a selenium server 30MB, firefox speaks the webdriver protocol natively, I dont see why a proxy server to a browser needs to be 30MB (40 including chromedriver?, it pretty much needs to launch browsers and proxy requests, the project that launches the browsers should probably be its own project for that matter.

If anyone can point me to a project working on that, I would highly appreciate it :)


I'm working on https://github.com/scriby/browser-harness. It's a little different in approach because it doesn't use selenium at all (rather it uses a websocket connection with the browser to control it).

It's considerably more lightweight and compatible with all browsers you care about, but you can't do everything you can do with selenium.

We've been using it for about 6 months at work and having good results.


This looks interesting and I have something I'd like to use it on, but the documentation could add a few things. How do I install this? How do I run a script?

Good point.

Check out https://github.com/scriby/browser-harness-bootstrap-tests for a full example. Browser harness itself is just a conduit between node and a browser - you need to provide the test framework yourself (mocha, vows, etc.).


Awesome! I'm going to try it out now.

Wow, this is awesome! Excellent work on this. Going to give it a spin over the weekend.

For the codebase is dark and full of terrors.

Is this a pun on the name, or a genuine critique of the source code?

As having a quick scan of the source code, it looks very well written! Especially for javascript, not many people can write javascript well.


I'm pretty sure it's a Game of Thrones pun :)

Yes, 'tis a pun :)

Definitely a pun, the "Night's Watch" is from Game of Thrones.


Both wrong; from the site:

"Nightwatch got its name from the famous painting The Night Watch by Dutch painter Rembrandt van Rijn. The masterpiece is prominently displayed in the Rijksmuseum, in Amsterdam - The Netherlands".

http://nightwatchjs.org/guide


...which was called such because the painting got dirty and buried under tons of varnish; the actual title is "The Company of captain Frans Banning Cocq and lieutenant Willem van Ruytenburch preparing to march out."

Thank you for this link ... it was an epic reading, a true classic indeed.

Looks similar to Angular's Protractor, but with more conventional (and easier to understand) syntax. Seems too easy not to try.

https://github.com/angular/protractor


I've been using Protractor for a month now and am eager to give Nightwatch a try:

- debugger is awful, horrible stack dumps (sometimes just no stack info, you have no idea where the test failed) - very slow - selectors for ng-repeats are so hard to decipher (I still don't get them)


We're having great success doing our integration tests without using Selenium.

At http://clara.io, our app is a fairly typical client-side Backbone.js app, so our integration tests can use standard backbone, mocha and jQuery constructs. Instead of using selenium, we use contructs like on('show').

The only thing that we actually use selenium for is for starting the browser from the command line.


Offtopic:

the line

> .waitForElementVisible("button[name=btnG]", 1000)

in the demo test caught my attention - what is a good way to achieve this in production code? i.e. execute a function when a certain element which matches the query becomes visible?

atm i'm using the DOMNodeInserted event (debounced)

> $(document).on('DOMNodeInserted', _.debounce(function(e, ui) {}, 100);


Take a look at Mutation Observers. The only problem might be browser support: http://caniuse.com/#search=MutationObserver

Good to see enough people interested in automation providers to make the front page.

After a few years building/maintaining a similar library I've found the key is simplifying peoples lives but making sure they can still do 'everything'.

Does Nightwatch implement the entire WebDriver JsonWire protocol or just the bits needed for the provided actions?

Cool stuff


I've created a similar project that uses jasmine and formats the test cases into general purpose flows.

The motivation is to economically (both in test suite run time and development time) test the system's many edge cases, including race conditions.

https://github.com/btakita/jasmine-flow

It's only dependency is jasmine. I use it with jsdom, so I can test all > 95% client's edge cases in a reasonable amount of time and confidence of the software working. This allows me to run the entire test suite before commits on mature projects.


Can anyone point me to a list of the various tools that automate web browsing (typically for automated testing) and the various layers of abstraction built on top of them?

Selenium (browser automating) might be what your looking for.

The Boston PHP group had a talk this week on integrating Selenium, phantomJS (headless browser) and Jenkins (continuous integration). Its php based talk, but at the end he showed the javascript version of the same tests.

https://github.com/balancerockmedia/boston-php-automated-tes...


is there a video of this presentation by any chance? I can't seem to find the JS tests in that repo either.


    pip install robotframework-selenium2library

    test.txt:
    *** Settings ***
    Library           Selenium2Library

    *** Test Cases ***
    Google The Night Watch
        [Setup]    Open Browser    https://google.com
        Title Should Be    Google
        Input Text    q    nightwatch
        Click Button    Google Search
        Wait Until Page Contains    The Night Watch
        [Teardown]    Close All Browsers


    pybot test.txt
Still haven't found anything that beats Robotframework when it comes to test automation. It's not just for web testing, it has many ready made libraries and creating your own is really easy.

Check it out http://robotframework.org/


This looks interesting thanks!.

All of the web testing over here at SMART is done via Robot Framework. It's verbose and tricky to use sometimes, but it's entirely accessible to a number of people who are not developers and can be very productive in it.

I'm surprised there's yet another JS implementation of the webdriver protocol. I wonder what was lacking in the existing frameworks from the author's perspective?

disclaimer: I work on https://github.com/admc/wd and https://github.com/jlipps/yiewd, which are other webdriver clients for Node


The API looks sweet. Looking forward to trying it out this weekend.

So similar to Soda (https://github.com/LearnBoost/soda) by the looks of it, but with Selenium server management and CI support.

So I'm about to get into building a large scale browser-based app testing solution, but the testing I'm doing isn't one of correctness, but of performance. This is a particularly persnickety problem since I need a solution where the probing itself doesn't introduce side effects that invalidate the test results. For example, many of the solutions I've seen use iFrames to isolate the test environment, but that introduces an entirely new and significant layer of redirection, especially when your results rely on GPU-related functions like CSS transforms.

Can anyone who has done lots of browser based testing shed light on what solutions out there introduce the fewest or no side effects when probing?


Awesome! I wonder how easy it would be to integrate http://galenframework.com with this

I'm curious why they didn't build on the "wd" implementation of the WebDriver protocol for Node.js: https://github.com/admc/wd

Personally I like just using "wd" along with a promise helper library or two.

Here's an example using q-proxy (https://npmjs.org/package/q-proxy) and q-step (https://npmjs.org/package/q-step). The result is a pretty nice syntax (admittedly nicer in CoffeeScript than JavaScript) and a lot more flexibility to do other logic:

    browser = QProxy(wd.promiseRemote("localhost", 4444))
    QStep(
      -> browser.init(browserName: "firefox")
      -> browser.get("https://www.facebook.com/")
      -> browser.elementById("email").type(credentials.email)
      -> browser.elementById("pass").type(credentials.password)
      -> browser.elementById("u_0_b").click()
    )
Or wd's own built-in promise chaining is pretty similar to Nightwatch.js as well:

  browser
    .init({browserName:'chrome'})
    .get("http://admc.io/wd/test-pages/guinea-pig.html")
    .title()
      .should.become('WD Tests')
    .elementById('i am a link')
    .click()
    .eval("window.location.href")
      .should.eventually.include('guinea-pig2')
    .back()
    .elementByCss('#comments').type('Bonjour!')
    .getValue().should.become('Bonjour!')
    .fin(function() { return browser.quit(); })
    .done();

Is there anything like this for an RDP connection?

This is great, I've put together some examples/tests pretty easily - can't wait to dive in deeper.

Any plans to integrate with Grunt.js?


Legal | privacy