News for hackers. Stuff that matters.
Re:Nightwatch.js by hpaavola on Friday January 31, 2014 @12:11PM (#7157702)

    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/

Re:Nightwatch.js by mmastrac on Friday January 31, 2014 @04:14PM (#7159225)
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.
Re:Nightwatch.js by noir_lord on Friday January 31, 2014 @12:40PM (#7157881)
This looks interesting thanks!.
Re:Nightwatch.js by tlrobinson on Friday January 31, 2014 @02:46PM (#7158762)
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();
Re:Nightwatch.js by daleharvey on Friday January 31, 2014 @07:58AM (#7156420)
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 :)

Re:Nightwatch.js by scriby on Friday January 31, 2014 @09:57AM (#7156922)
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.

Re:Nightwatch.js by Scriptor on Friday January 31, 2014 @11:13AM (#7157356)
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?
Re:Nightwatch.js by scriby on Friday January 31, 2014 @12:14PM (#7157732)
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.).

Re:Nightwatch.js by Scriptor on Friday January 31, 2014 @01:49PM (#7158370)
Awesome! I'm going to try it out now.
Re:Nightwatch.js by cnp on Friday January 31, 2014 @01:44PM (#7158331)
Wow, this is awesome! Excellent work on this. Going to give it a spin over the weekend.
Re:Nightwatch.js by sh1989 on Friday January 31, 2014 @08:00AM (#7156428)
For the codebase is dark and full of terrors.
Re:Nightwatch.js by mattmanser on Friday January 31, 2014 @08:12AM (#7156468)
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.

Re:Nightwatch.js by mcintyre1994 on Friday January 31, 2014 @08:13AM (#7156470)
I'm pretty sure it's a Game of Thrones pun :)
Re:Nightwatch.js by sh1989 on Friday January 31, 2014 @09:43AM (#7156831)
Yes, 'tis a pun :)
Re:Nightwatch.js by civild on Friday January 31, 2014 @08:13AM (#7156471)
Definitely a pun, the "Night's Watch" is from Game of Thrones.
Re:Nightwatch.js by a3_nm on Friday January 31, 2014 @08:16AM (#7156477)
It could also be referring to the classic https://research.microsoft.com/en-us/people/mickens/thenight...
Re:Nightwatch.js by stingraycharles on Friday January 31, 2014 @08:22AM (#7156493)
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

Re:Nightwatch.js by mbq on Friday January 31, 2014 @10:58AM (#7157267)
...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."
Re:Nightwatch.js by delian66 on Friday January 31, 2014 @12:45PM (#7157900)
Thank you for this link ... it was an epic reading, a true classic indeed.
Re:Nightwatch.js by bryanlarsen on Friday January 31, 2014 @09:02AM (#7156639)
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.

Re:Nightwatch.js by hesslau_ on Friday January 31, 2014 @09:21AM (#7156706)
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);

Re:Nightwatch.js by MDCore on Friday January 31, 2014 @11:26AM (#7157422)
Take a look at Mutation Observers. The only problem might be browser support: http://caniuse.com/#search=MutationObserver
Re:Nightwatch.js by malandrew on Friday January 31, 2014 @12:58PM (#7157991)
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?

Re:Nightwatch.js by briantakita on Friday January 31, 2014 @09:32AM (#7156780)
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.

Re:Nightwatch.js by jlipps on Friday January 31, 2014 @12:16PM (#7157741)
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

Re:Nightwatch.js by stirno on Friday January 31, 2014 @09:21AM (#7156709)
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

Re:Nightwatch.js by pkmishra on Friday January 31, 2014 @07:37AM (#7156351)
what benefit does it have in comparison to casperjs?
Re:Nightwatch.js by jffry on Friday January 31, 2014 @07:44AM (#7156379)
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
Re:Nightwatch.js by victorhooi on Friday January 31, 2014 @07:57AM (#7156418)
Also, this is Node.js compatible - CasperJS is not.
Re:Nightwatch.js by camus2 on Friday January 31, 2014 @08:06AM (#7156448)
whatever casperjs is as compatible with nodejs as this stuff.This stuff uses selenium,it's not a stand alone solution.
Re:Nightwatch.js by neebz on Friday January 31, 2014 @07:39AM (#7156364)
casper works with phantomjs. nightwatch works with selenium.
Re:Nightwatch.js by neals on Friday January 31, 2014 @07:58AM (#7156422)
Thank you for introducing me to phantomjs, just the thing I need.
Re:Nightwatch.js by deelowe on Friday January 31, 2014 @09:50AM (#7156878)
If you like phantom, check out casper. It makes phantom much easier to use
Re:Nightwatch.js by joemaller1 on Friday January 31, 2014 @08:32AM (#7156539)
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

Re:Nightwatch.js by mck- on Friday January 31, 2014 @02:51PM (#7158789)
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)

Re:Nightwatch.js by mcantelon on Friday January 31, 2014 @12:53PM (#7157948)
So similar to Soda (https://github.com/LearnBoost/soda) by the looks of it, but with Selenium server management and CI support.
Re:Nightwatch.js by j_s on Friday January 31, 2014 @11:21AM (#7157394)
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?
Re:Nightwatch.js by acomjean on Friday January 31, 2014 @12:09PM (#7157676)
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...

Re:Nightwatch.js by Aco- on Friday January 31, 2014 @01:16PM (#7158134)
is there a video of this presentation by any chance? I can't seem to find the JS tests in that repo either.
Re:Nightwatch.js by acomjean on Tuesday February 04, 2014 @11:47AM (#7178540)
Re:Nightwatch.js by lun4r on Friday January 31, 2014 @02:25PM (#7158617)
Awesome! I wonder how easy it would be to integrate http://galenframework.com with this
Re:Nightwatch.js by hodoublesy on Saturday February 01, 2014 @09:55AM (#7161780)
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?

Re:Nightwatch.js by bevacqua on Friday January 31, 2014 @07:44AM (#7156381)
How is it any different from wd.js?
Re:Nightwatch.js by ChrisAntaki on Friday January 31, 2014 @12:50PM (#7157930)
The API looks sweet. Looking forward to trying it out this weekend.
Re:Nightwatch.js by JungleGymSam on Friday January 31, 2014 @04:39PM (#7159344)
Is there anything like this for an RDP connection?
[deleted]
Re:Nightwatch.js by junto on Friday January 31, 2014 @07:34AM (#7156343)
What other names have you used then?
Re:Nightwatch.js by wlievens on Friday January 31, 2014 @07:33AM (#7156340)
Or Rembrandt paintings?
Re:Nightwatch.js by yread on Friday January 31, 2014 @07:39AM (#7156359)
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