Dalek.js - simple functional testing of web applications

    Do you know what Selenium and / or PhantomJS are ? And what do they eat with? Then, perhaps, you will be interested in the Dalek.js project - a cross-browser utility for testing web applications.

    Dalek.js allows you to write tests that go to web pages, click links, fill out forms, submit data and take screenshots. The tests written using Selenium or Phantom.js do the same and even more, what’s the catch?



    But! See how simple this test is.
    test.js
    module.exports = {
      'Page title is correct': function (test) {
        test
         .open('http://google.com')
         .assert.title().is('Google', 'It has title')
         .done();
        }
    };
    

    Open google.com in a browser and make sure that the title of the page really says 'Google'.

    To start it you need to:
    a) install Dalek.js and drivers for the desired browsers (PhantomJS works out of the box) in the directory of the previously created node project (although the project itself is essentially unnecessary)
    For example: Dalek.js + Chrome Driver
    $ npm install dalek-cli -g
    $ npm install dalekjs --save-dev
    $ npm install dalek-browser-chrome --save-dev
    

    b) and execute the command:
    $ dalek test.js    //для тестирования в PhantomJS
    $ dalek test.js  -b chrome    //для тестирования в Chrome
    


    Another simple test from the documentation:
    module.exports = {
    'Amazon does its thing': function (test) {
      test
        .open('http://www.amazon.com/')
        .type('#twotabsearchtextbox', 'Blues Brothers VHS')
        .click('.nav-submit-input')
        .waitForElement('#result_0')
        .assert.text('#result_0 .newaps a span').is('The Blues Brothers')
        .done();
    }
    };
    

    On Amazon, we’re looking for the Blues Brothers video cassette and making sure that the search results really contain what we are looking for.

    I will not continue to copy-paste the official documentation and examples (everything is detailed and understandable at www.dalekjs.com ), but I will ask you to support the project with your attention. Why?

    Having decided to master the use of PhantomJS for testing instead of Selenium, I began to search on which framework (Mocha, Jasmine, ...) it would be more convenient to write tests. Word for word, and now Google gave a link to this project. Writing a test and running it first in visual mode (on Chrome) and then in console mode (on PhantomJS) came out very quickly.

    I believe that Dalek.js has several convenient features: chain-style function calls with a minimum of parameters, it does not require super-shamanistic dances with installation, it is well documented. The project has a large number of open bugs and promises to add functionality (for example, at least, you want mouse movements, uploading files to forms).

    The community’s attention in the form of an increase in the number of stars on GitHub and tweets in the media space may at least slightly contribute to the activity of the Dalek.js development, which several guys from Germany have been sawing for about a year, what do you think?

    Off
    site Dalek.js Dalek.js on GitHub
    Dalek.js on Twitter

    Also popular now: