MANISH ZOPE
MANISH ZOPE

Reputation: 1201

How to debug functional testing with intern js

I am new to functional testing and to intern. Can anybody help me with the functional testing of the web pages which require authentication i.e. web pages behind the session. I have installed the selenium web driver and able to test the login page and some static pages without any issues.

e.g. /myproj/login is login page. I am able to test it. Now when I am trying to test /myproj/home/index then browser is redirecting to login page. I want to test this page what should be the steps? Some code snippet would really make the things clear.

registerSuite({
        name: 'demo',

        'submit form': function () {  
            remote = this.remote;
            return remote
                .get(require.toUrl('https://localhost/login'))
                .findById('username')
                    .click()
                    .type('test')
                .end()
                .findById('password')
                    .click()
                    .type('test123')
                .end()
                .findByName('submit')
                    .click()
                .end()
                .then(pollUntil('return document.getElementById("osp_homepage_metric_selection_bar");', 30000))
                .findById('osp_show_help_popup_trigger_parent')
                .getVisibleText()
                .then(function(resultText){
                    assert.equal(resultText, '<i class=" icon-question-sign"></i>','Test Failed!!!');
                });
        },

        'landing page': function () {    
            return remote
                .setFindTimeout(Infinity)
                .findById('show_help_popup_trigger_parent') 
                .getVisibleText()
                .then(function (resultText) {
                    assert.equal(resultText, '<i class=" icon-question-sign"></i>','Test Failed!!!');

                });
        }


    });

Thanks In Advance

Manish

Upvotes: 1

Views: 1544

Answers (2)

khollenbeck
khollenbeck

Reputation: 16157

Intern JS Debugging Functional Tests for Intellij Users:

Take the following directory structure for example.

-C
 -root
   -node_modules
      -intern
         -bin
            intern-runner.js
   -tests

Set up new debug configurations for a Node Application.

enter image description here

After setting your debug configurations you can then proceed to debug your functional tests. Just set a breakpoint in your JS files and hit the debug button.

enter image description here

Upvotes: 1

jason0x43
jason0x43

Reputation: 3363

One possibility is to use a test server that doesn't require you to login.

Another option would be to login to your site in your functional test. Fill in the username and password (or whatever you use to login) on the login page and submit it:

.findById('username')
.type('bob123')
.end()
.findById('password')
.type('somepassword')
.end()
.findById('submit')
.click()

Then wait for the page you're interested in to load completely and continue testing:

.then(pollUntil(...))
// continue testing

If the login process is slow, you may need to increase the timeout for your test using this.async.

Upvotes: 1

Related Questions