1

I started reading about automated testing of web apps a couple of days ago, and after a lot of trial and error (and tutorial) finally somehow managed to run couple of Intern functional tests both locally and on BrowserStack but one thing that I can't wrap my head around is the reporting.

For example, i have a simple test that fills in some login page data, submits the form, and checks if everything is ok.

The code might look something like this:

define(function (require) {
    var registerSuite = require('intern!object');
    var assert = require('intern/chai!assert');
    var fs = require('intern/dojo/node!fs');

    registerSuite({
        name: 'index',

        'Log in test': function () {
            var user = 'username';
            var pass = 'pAsssWord';

            return this.remote                
                .get(require.toUrl('http://localhost/MyApp/'))
                .setFindTimeout(20000)                              

                //fill in username
                .findDisplayedByCssSelector('#panelUsernamePassword .usernameField')                
                    .click()
                    .clearValue()
                    .type(user)
                    .end()

                //fill in password
                .findDisplayedByCssSelector('#panelUsernamePassword .passwordField')                
                    .click()
                    .clearValue()
                    .type(pass)
                    .end()
                .takeScreenshot()
                .then(function(data) {
                    fs.writeFileSync("after-data-filled.png", data, 'base64');
                })  
                //click login button
                .findDisplayedByCssSelector('#panelUsernamePassword button')
                .click()
                .end()
                .sleep(500)
                .takeScreenshot()
                .then(function(data) {
                    fs.writeFileSync("after-login-pressed.png", data, 'base64');
                })
                //click popup close button
                .findDisplayedByCssSelector('div[id$="close-button"]')
                .click()
                .end()
                .sleep(500)
                .takeScreenshot()
                .then(function(data) {
                    fs.writeFileSync("no-popup.png", data, 'base64');
                })              
                .end();
        }
    });
});

After running intern-runner config=tests/intern.js

the test will pass, and I'll have in a console window something like

    Listening on 0.0.0.0:9000
    Tunnel started
    ‣ Created session chrome 39 on WINDOWS (c7873066-b185-4025-a93a-829ea0fdb364)
    ✓ chrome 39 on WINDOWS - index - Log in test (15.393s)
    No unit test coverage for chrome 39 on WINDOWS
    chrome 39 on WINDOWS: 0/1 tests failed

OK, if the test passes, I don't really need much info, all is well, but on the other hand if in the test i have something like:

.findDisplayedByCssSelector('#thisIsSomethingThatIsNotOnThePage')

Only info I get about the failure is:

NoSuchElement: An element could not be located on the page using the given search parameters.

Is there any way to know which element on the page is not found? Maybe I'm doing something wrong?

Thank you

EDIT:

Full error summary:

× chrome 47 on WINDOWS - index - Log in test
NoSuchElement: An element could not be located on the page using the given search parameters.
  at <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\leadfoot\lib\findDisplayed.js:37:21>
  at <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\Promise.ts:393:15>
  at run  <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\Promise.ts:237:7>
  at <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\nextTick.ts:44:3>
  at doNTCallback0  <node.js:419:9>
  at process._tickCallback  <node.js:348:13>
  at Command.findDisplayed  <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\leadfoot\Command.js:23:10>
  at Command.prototype.(anonymous function) [as findDisplayedByCssSelector]  <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\leadfoot\lib\strategies.js:28:16>
  at Test.registerSuite.Log in test [as test]  <tests\functional\index.js:21:6>
  at <..\..\AppData\Roaming\npm\node_modules\intern\lib\Test.js:211:24>
  at <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\Promise.ts:393:15>
  at runCallbacks  <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\Promise.ts:11:11>
  at <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\Promise.ts:317:4>
  at run  <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\Promise.ts:237:7>
  at <..\..\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\nextTick.ts:44:3>
  at doNTCallback0  <node.js:419:9>
Slavenko Miljic
  • 3,836
  • 2
  • 23
  • 36

1 Answers1

1

I don’t know how you say that is the only information you get about the error. The stack trace for errors, which is shown immediately below the error message you pasted, will include the exact line in your test that caused the error. The error message also includes the parameters that were sent to the server, which names exactly what element was searched for. For example, I just ran a test to demonstrate normal error output:

Listening on 0.0.0.0:9000
Tunnel started
‣ Created session firefox on any platform (fb89e8af-73d6-4c90-bfe7-82820bf6e312)
× firefox on any platform - error handling demo (1.34s)
NoSuchElement: [POST http://localhost:4444/wd/hub/session/fb89e8af-73d6-4c90-bfe7-82820bf6e312/element / {"using":"css selector","value":".missing"}] Unable to locate element: {"method":"css selector","selector":".missing"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: [redacted]
Driver info: driver.version: unknown
  at ProxiedSession._post  <node_modules/intern/node_modules/leadfoot/Session.js:59:30>
  at ProxiedSession.Session.find  <node_modules/intern/node_modules/leadfoot/Session.js:1055:15>
  […]
  at Test.registerSuite.greeting form [as test]  <tests/functional/index.js:12:6>
  […]

As you can see, the error message from Intern includes explicit information about the endpoint that failed (/element), the query that failed (.missing using CSS selector), and the line of the test that failed (tests/functional/index.js line 12 column 6). It’s hard to give much more information than that! If you aren’t seeing this information then you probably have some system misconfiguration, though I don’t know what that might be (really old or buggy Node.js? Chrome 39 is certainly ancient).

C Snover
  • 17,908
  • 5
  • 29
  • 39
  • Well, that's all the info I get. I've edited my question to include the full stack, I've used config files from the official tutorial and the node version is v4.2.3. I'm probably doing something wrong in the test itself, maybe I need to somehow explicitly throw an error on the `findDisplayedByCssSelector` line – Slavenko Miljic Dec 22 '15 at 07:53
  • At least, now I know what kind of response I should be expecting, I'll try to look into this further. Thank you. – Slavenko Miljic Dec 22 '15 at 08:17