
Nightwatch.js - Lazare
http://nightwatchjs.org/
======
hpaavola

        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/](http://robotframework.org/)

~~~
mmastrac
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.

------
tlrobinson
I'm curious why they didn't build on the "wd" implementation of the WebDriver
protocol for Node.js: [https://github.com/admc/wd](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](https://npmjs.org/package/q-proxy)) and
q-step ([https://npmjs.org/package/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();

------
daleharvey
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 :)

~~~
scriby
I'm working on [https://github.com/scriby/browser-
harness](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.

~~~
Scriptor
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?

~~~
scriby
Good point.

Check out [https://github.com/scriby/browser-harness-bootstrap-
tests](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.).

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

------
sh1989
For the codebase is dark and full of terrors.

~~~
mattmanser
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.

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

~~~
sh1989
Yes, 'tis a pun :)

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

At [http://clara.io](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.

------
hesslau_
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);

~~~
MDCore
Take a look at Mutation Observers. The only problem might be browser support:
[http://caniuse.com/#search=MutationObserver](http://caniuse.com/#search=MutationObserver)

------
malandrew
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?

------
briantakita
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](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.

------
jlipps
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](https://github.com/admc/wd) and
[https://github.com/jlipps/yiewd](https://github.com/jlipps/yiewd), which are
other webdriver clients for Node_

------
stirno
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

------
pkmishra
what benefit does it have in comparison to casperjs?

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

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

------
joemaller1
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](https://github.com/angular/protractor)

~~~
mck-
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)

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

------
j_s
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?

~~~
acomjean
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...](https://github.com/balancerockmedia/boston-php-automated-testing)

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

~~~
acomjean
[https://www.youtube.com/watch?v=dbbUXjRUMPo](https://www.youtube.com/watch?v=dbbUXjRUMPo)

------
lun4r
Awesome! I wonder how easy it would be to integrate
[http://galenframework.com](http://galenframework.com) with this

------
hodoublesy
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?

------
bevacqua
How is it any different from wd.js?

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

------
JungleGymSam
Is there anything like this for an RDP connection?

